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

View File

@@ -1,16 +1,22 @@
import * as core from '@actions/core'
import {wait} from './wait'
import axios from 'axios';
async function run(): Promise<void> {
try {
const ms: string = core.getInput('milliseconds')
core.debug(`Waiting ${ms} milliseconds ...`) // debug is only output if you set the secret `ACTIONS_STEP_DEBUG` to true
const sendkey:string = core.getInput('sendkey');
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) {
if (error instanceof Error) core.setFailed(error.message)
}