forked from wes-lin/Cloud189Checkin
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (77 loc) · 2.53 KB
/
Copy pathrun.yml
File metadata and controls
88 lines (77 loc) · 2.53 KB
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
84
85
86
87
88
name: Cloud check in action
on:
push:
branches:
- main
watch:
types: started
workflow_dispatch:
schedule:
- cron: 35 2 * * *
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: user
steps:
- name: 🔀 random delay 0-300 seconds
run: sleep $((RANDOM % 301))
- name: 🔌 Check out code
uses: actions/checkout@main
- name: 🔨 Setup Node.js environment
uses: actions/setup-node@main
with:
node-version: 18
cache: npm
- name: 👾 Check if Debug is true
if: vars.debug == '1'
run: |
echo "CLOUD189_VERBOSE=1" >> $GITHUB_ENV
- name: 📹 Restore cached Cookie
id: cache-cookie-restore
uses: actions/cache/restore@v4
with:
path: .token
key: cloud189-token-${{ hashFiles('.token/*.json') }}
restore-keys: cloud189-token-
- name: 🔧 Init secrets
uses: shine1594/secrets-to-env-action@master
with:
secrets: ${{ toJSON(secrets) }}
secrets_env: production
prefix_prod: ""
file_name_prod: .env
- name: 📡 Init dependencies
run: npm install
- name: 🚀 Run
uses: nick-fields/retry@master
with:
timeout_minutes: 30
max_attempts: 3
command: npm start
- name: 🔑 Compute token hash
if: always()
run: |
NEW_HASH=$(find .token -name '*.json' -exec sha256sum {} \; 2>/dev/null | sha256sum | cut -d' ' -f1)
echo "TOKEN_HASH=${NEW_HASH}" >> $GITHUB_ENV
- name: 📹 Save cached Cookie
if: always() && env.TOKEN_HASH != ''
uses: actions/cache/save@v4
with:
path: .token
key: cloud189-token-${{ env.TOKEN_HASH }}
- name: 🚗 Keep Running
if: github.event_name == 'schedule'
run: |
git config --local user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
git remote set-url origin https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}
git pull --rebase --autostash
git commit --allow-empty -m "Keep Running..."
git push
- name: 🎉 Delete old workflow run
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 50