-
Notifications
You must be signed in to change notification settings - Fork 277
75 lines (60 loc) · 2.2 KB
/
cron_bypassCF.yaml
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
name: bypassCF cron (use this)
on:
schedule:
# 每天 UTC 时间 18:00 运行
- cron: "0 18 * * *"
workflow_dispatch: # 允许手动触发
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20 # 设置作业超时时间为20分钟
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3 # 检出仓库
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm install
sudo apt install -y xvfb
- name: Load environment variables
run: |
echo "Debug: Checking if .env file exists..."
# 检查 .env 文件是否存在
if [ -f .env ]; then
echo ".env file found. Loading environment variables from .env file"
# 加载 .env 文件中的默认值
set -a
source .env
set +a
echo "Loaded .env variables:"
cat .env
else
echo ".env file not found. Skipping loading."
fi
# 如果 GitHub Secrets 中设置了环境变量,则覆盖默认值
if [ -n "${{ secrets.USERNAMES }}" ] && [ ! -z "${{ secrets.USERNAMES }}" ]; then
echo "Using GitHub Secret for USERNAMES"
echo "USERNAMES=${{ secrets.USERNAMES }}" >> $GITHUB_ENV
else
echo "USERNAMES=${USERNAMES}" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.PASSWORDS }}" ] && [ ! -z "${{ secrets.PASSWORDS }}" ]; then
echo "Using GitHub Secret for PASSWORDS"
echo "PASSWORDS=\"${{ secrets.PASSWORDS }}\"" >> $GITHUB_ENV
else
echo "PASSWORDS=\"${PASSWORDS}\"" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.WEBSITE }}" ] && [ ! -z "${{ secrets.WEBSITE }}" ]; then
echo "Using GitHub Secret for WEBSITE"
echo "WEBSITE=${{ secrets.WEBSITE }}" >> $GITHUB_ENV
else
echo "WEBSITE=${WEBSITE}" >> $GITHUB_ENV
fi
shell: bash
- name: Run a script
run: xvfb-run node bypasscf.js