forked from 750421628/39shouting
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (62 loc) · 2.15 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: daily-task
on:
push: # push触发
branches: [ main ]
workflow_dispatch: # 手动触发
schedule: # 计划任务触发
- cron: '0 */8 * * *' # cron表达式,Actions时区是UTC时间,所以要往前推8个小时(4-23)
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}