Daily Answer Script #116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Daily Answer Script | |
on: | |
schedule: | |
- cron: "30 22 * * *" | |
workflow_dispatch: | |
inputs: | |
account: | |
description: "账号" | |
required: false | |
password: | |
description: "密码" | |
required: false | |
date: | |
description: "日期" | |
required: false | |
env: | |
ACCOUNT: ${{ github.event.inputs.account || secrets.ACCOUNT }} | |
PASSWORD: ${{ github.event.inputs.password || secrets.PASSWORD }} | |
KEY: ${{ secrets.KEY }} | |
IV: ${{ secrets.IV }} | |
DATE: ${{ github.event.inputs.date }} | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
jobs: | |
run-script: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Bun environment | |
id: cache-bun | |
uses: actions/cache@v3 | |
with: | |
path: ~/.bun | |
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} | |
restore-keys: | | |
${{ runner.os }}-bun- | |
- name: Setup Bun | |
if: steps.cache-bun.outputs.cache-hit != 'true' | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lockb') }} | |
restore-keys: | | |
${{ runner.os }}-node-modules- | |
- name: Install dependencies if needed | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: bun install | |
- name: Run Answer Script and Send Telegram Message | |
run: | | |
bun run index.ts || true | |
output=$(cat output.txt) | |
curl -s -X POST https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage -d chat_id=${TELEGRAM_CHAT_ID} -d text="$output" |