-
Notifications
You must be signed in to change notification settings - Fork 251
66 lines (55 loc) · 2.33 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
name: readLike(自动阅读随机点赞)
# GitHub.secrets优先级最高,即使没有设置对应的变量,它也会读取,这时变量为空值,导致报错,.env读取的变量无法覆盖这个值,使用了${PASSWORD_ESCAPED//\#/\\#}来对#转义,需要两个\,但是我直接在env文件使用这种方法是不行的,GitHub action是有效
on:
schedule:
# 每天 UTC 时间 18:40 运行
- cron: "40 18 * * *"
workflow_dispatch: # 允许手动触发
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 25 # 设置作业超时时间为20分钟
strategy:
matrix:
node-version: [20.x]
env:
# 在作业级别设置环境变量
USERNAMES: ${{ secrets.USERNAMES }}
PASSWORDS: ${{ secrets.PASSWORDS }}
RUN_TIME_LIMIT_MINUTES: ${{secrets.RUN_TIME_LIMIT_MINUTES}}
TELEGRAM_BOT_TOKEN: ${{secrets.TELEGRAM_BOT_TOKEN}}
TELEGRAM_CHAT_ID: ${{secrets.TELEGRAM_CHAT_ID}}
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
#github action设置的action环境变量会完全替换掉env文件的读取,所以需要在action里手动进行加载env文件
- 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:"
else
echo ".env file not found. Skipping loading."
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: node bypasscf.js --USERNAMES "$USERNAMES" --PASSWORDS "$PASSWORDS" --WEBSITE "$WEBSITE"