Skip to content

Commit

Permalink
Create daily-task.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuJian2 authored Feb 7, 2021
1 parent d5e84d6 commit c617cde
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/daily-task.yml
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

0 comments on commit c617cde

Please sign in to comment.