save
This commit is contained in:
17
action.yml
17
action.yml
@@ -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'
|
||||
|
||||
20
src/main.ts
20
src/main.ts
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user