From a213ecb56814c59b6ce02438af43e8c9e04067f3 Mon Sep 17 00:00:00 2001 From: Easy Date: Sat, 4 Feb 2023 16:12:23 +0800 Subject: [PATCH] save --- action.yml | 17 +++++++++++------ src/main.ts | 20 +++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/action.yml b/action.yml index 345e2f4..b2c8250 100644 --- a/action.yml +++ b/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' diff --git a/src/main.ts b/src/main.ts index 98325c4..934da53 100644 --- a/src/main.ts +++ b/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 { 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) }