This commit is contained in:
Easy
2023-02-04 16:12:23 +08:00
committed by GitHub
parent 17710666b0
commit a213ecb568
2 changed files with 24 additions and 13 deletions

View File

@@ -1,11 +1,16 @@
name: 'Your name here' name: 'ServerChan · Server酱通知'
description: 'Provide a description here' description: 'Send wechat notice via serverchan'
author: 'Your name or organization here' author: 'EasyChen'
inputs: inputs:
milliseconds: # change this sendkey:
required: true required: true
description: 'input description here' description: 'SendKey 可在 sct.ftqq.com 免费申请'
default: 'default value if applicable' title:
required: true
description: '消息标题'
desp:
description: '消息详细说明支持markdown'
runs: runs:
using: 'node16' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'

View File

@@ -1,16 +1,22 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {wait} from './wait' import axios from 'axios';
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
const ms: string = core.getInput('milliseconds') const sendkey:string = core.getInput('sendkey');
core.debug(`Waiting ${ms} milliseconds ...`) // debug is only output if you set the secret `ACTIONS_STEP_DEBUG` to true const title:string = core.getInput('title');
const desp:string|boolean = core.getInput('desp')??false;
const url:string = `https://sctapi.ftqq.com/${sendkey}.send`;
// send request via form
let params = new URLSearchParams();
params.append( title, title );
if( desp ) params.append( desp, desp);
const ret = await axios.post( url , params );
console.log( ret, ret.data );
core.debug(new Date().toTimeString())
await wait(parseInt(ms, 10))
core.debug(new Date().toTimeString())
core.setOutput('time', new Date().toTimeString())
} catch (error) { } catch (error) {
if (error instanceof Error) core.setFailed(error.message) if (error instanceof Error) core.setFailed(error.message)
} }