Skip to content

Commit 9c4d2c4

Browse files
authored
Update check.yml
1 parent 28b715f commit 9c4d2c4

1 file changed

Lines changed: 116 additions & 26 deletions

File tree

.github/workflows/check.yml

Lines changed: 116 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,139 @@
1-
# .github/workflows/check.yml
2-
3-
name: 检测Serv00开放注册
1+
name: NodeLoc Auto Checkin
42

53
on:
64
schedule:
7-
- cron: '0 23 * * *'
8-
5+
# 每天UTC 8:00运行(北京时间16:00)
6+
- cron: '0 8 * * *'
97
workflow_dispatch:
8+
# 支持手动触发
109

1110
jobs:
12-
run-checker:
13-
# 在最新的Ubuntu虚拟机上运行
11+
checkin:
1412
runs-on: ubuntu-latest
1513

1614
steps:
17-
# 第一步:检出你的代码
18-
# 意思是把你的仓库代码下载到虚拟机里
1915
- name: Checkout repository
2016
uses: actions/checkout@v4
2117

22-
# 第二步:设置Python环境
23-
# 我们指定使用Python 3.9,你也可以用3.10等
2418
- name: Set up Python
2519
uses: actions/setup-python@v5
2620
with:
27-
python-version: '3.9'
21+
python-version: '3.10'
22+
cache: 'pip'
2823

29-
# 第三步:安装 requirements.txt 中列出的所有Python库
30-
- name: Install Python dependencies
24+
- name: Install system dependencies
3125
run: |
32-
python -m pip install --upgrade pip
33-
pip install -r requirements.txt
26+
sudo apt-get update
27+
sudo apt-get install -y \
28+
wget \
29+
curl \
30+
unzip \
31+
xvfb \
32+
libnss3 \
33+
libatk-bridge2.0-0 \
34+
libdrm2 \
35+
libxkbcommon0 \
36+
libxcomposite1 \
37+
libxdamage1 \
38+
libxrandr2 \
39+
libgbm1 \
40+
libatspi2.0-0 \
41+
libxshmfence1 \
42+
libasound2-plugins
3443
35-
# 第四步:【最关键】安装Google Chrome浏览器
36-
# Selenium需要一个真实的浏览器来驱动
37-
- name: Install Google Chrome
44+
- name: Install Chrome
3845
run: |
46+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
47+
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
3948
sudo apt-get update
49+
# 安装最新稳定版 Chrome
4050
sudo apt-get install -y google-chrome-stable
4151
42-
# 第五步:运行你的Python脚本
43-
- name: Run the checker script
44-
# 这一步会执行你的 checker.py 文件
45-
# 我们通过 env 关键字将GitHub Secrets安全地传递给脚本
46-
run: python checker.py
52+
- name: Verify Chrome installation
53+
run: google-chrome --version
54+
55+
- name: Install Python dependencies
56+
run: |
57+
pip install --upgrade pip
58+
pip install -r requirements.txt
59+
60+
- name: Run NodeLoc Auto Checkin
61+
env:
62+
NL_COOKIE: ${{ secrets.NL_COOKIE }}
63+
run: |
64+
# 使用Xvfb在无头模式下运行Chrome
65+
Xvfb :99 -screen 0 1920x1080x24 &
66+
export DISPLAY=:99
67+
68+
# 运行签到脚本
69+
python main.py
70+
71+
- name: Upload log file
72+
if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: checkin-log
76+
path: checkin.log
77+
retention-days: 7
78+
79+
- name: Send Slack notification on failure
80+
if: failure()
81+
uses: 8398a7/action-slack@v3
82+
with:
83+
status: ${{ job.status }}
84+
text: 'NodeLoc 签到失败,请检查Cookie配置'
4785
env:
48-
BARK_KEY: ${{ secrets.BARK_KEY }}
49-
BARK_SERVER_URL: ${{ secrets.BARK_SERVER_URL }}
86+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
87+
88+
- name: Send Bark notification
89+
if: always()
90+
run: |
91+
# 获取运行状态
92+
STATUS="${{ job.status }}"
93+
94+
# 构建消息内容
95+
if [ "$STATUS" = "success" ]; then
96+
TITLE="✅ NodeLoc 签到成功"
97+
BODY="所有账号签到完成,请查看日志"
98+
else
99+
TITLE="❌ NodeLoc 签到失败"
100+
BODY="签到过程中出现错误,请检查Cookie配置"
101+
fi
102+
103+
# 发送Bark通知(如果配置了BARK_KEY)
104+
if [ -n "${{ secrets.BARK_KEY }}" ]; then
105+
# 构建JSON数据
106+
JSON_DATA=$(jq -n \
107+
--arg title "$TITLE" \
108+
--arg body "$BODY" \
109+
'{
110+
"title": $title,
111+
"body": $body,
112+
"automaticallyCopy": true,
113+
"copy": $body
114+
}')
115+
116+
# 使用自建服务器或官方服务器
117+
if [ -n "${{ secrets.BARK_SERVER }}" ]; then
118+
# 自建服务器地址(例如:https://your-server.com)
119+
BARK_URL="${{ secrets.BARK_SERVER }}/${{ secrets.BARK_KEY }}"
120+
else
121+
# 官方服务器
122+
BARK_URL="https://api.day.app/${{ secrets.BARK_KEY }}"
123+
fi
124+
125+
# 发送通知
126+
echo "发送Bark通知到: $BARK_URL"
127+
echo "请求数据: $JSON_DATA"
128+
curl -s -w "\nHTTP状态码: %{http_code}\n" "$BARK_URL" \
129+
-H "Content-Type: application/json" \
130+
-d "$JSON_DATA" \
131+
-X POST
132+
if [ $? -eq 0 ]; then
133+
echo "Bark通知发送成功"
134+
else
135+
echo "Bark通知发送失败,但不影响主流程"
136+
fi
137+
else
138+
echo "未配置BARK_KEY,跳过Bark通知"
139+
fi

0 commit comments

Comments
 (0)