forked from 1373486245/AutoSign
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ChuJian2
authored
Feb 7, 2021
1 parent
d5e84d6
commit c617cde
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: daily-task | ||
|
||
|
||
on: | ||
|
||
push: # push触发 | ||
branches: [ main ] | ||
workflow_dispatch: # 手动触发 | ||
schedule: # 计划任务触发 | ||
#- cron: '*/30 20-23,0-15 * * *' # cron表达式,Actions时区是UTC时间,所以要往前推8个小时(4-23) | ||
- cron: '30 * * * *' | ||
|
||
|
||
jobs: | ||
daily-task: | ||
if: github.event.repository.owner.id == github.event.sender.id | ||
|
||
|
||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [12] | ||
node-registry: ['https://registry.npmjs.org'] | ||
|
||
steps: | ||
|
||
# 检出 | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
# 设置服务器时区为东八区 | ||
- name: Set time zone | ||
run: sudo timedatectl set-timezone 'Asia/Shanghai' | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
registry-url: ${{ matrix.node-registry }} | ||
|
||
- name: Get npm cache directory | ||
id: npm-cache | ||
run: | | ||
echo "::set-output name=dir::$(npm config get cache)" | ||
- name: restore npm cache | ||
uses: actions/cache@v2 | ||
id: use-npm-cache | ||
with: | ||
path: ${{ steps.npm-cache.outputs.dir }} | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: restore npm dependencies | ||
uses: actions/cache@v2 | ||
id: use-npm-depends | ||
with: | ||
path: | | ||
node_modules | ||
*/*/node_modules | ||
key: ${{ runner.os }}-depends-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: restore task cache | ||
uses: actions/cache@v2 | ||
id: use-task-cache | ||
with: | ||
path: | | ||
/home/runner/.AutoSignMachine | ||
key: ${{ runner.os }}-task-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install dependencies | ||
if: steps.use-npm-cache.outputs.cache-hit != 'true' || steps.use-npm-depends.outputs.cache-hit != 'true' | ||
run: npm install | ||
|
||
# 运行 unicom 签到任务 | ||
- name: Run unicom daily task | ||
|
||
env: | ||
user: ${{secrets.unicom_user}} | ||
password: ${{secrets.unicom_password}} | ||
appid: ${{secrets.unicom_appid}} | ||
run: node index.js unicom --user=${user} --password=${password} --appid=${appid} --tryrun |