File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Get Duya Subscription
2-
3- on :
4- workflow_dispatch : # 手动触发
5-
6- jobs :
7- get-sub :
8- runs-on : ubuntu-latest
9- steps :
10- - name : Checkout repository
11- uses : actions/checkout@v4
12-
13- - name : Set up Python 3.10
14- uses : actions/setup-python@v5
15- with :
16- python-version : ' 3.10'
17-
18- - name : Install required packages
19- run : pip install requests
20-
21- - name : Run duya.py script
22- id : run-script
23- run : |
24- # 运行脚本并捕获输出(若脚本报错,这一步会失败)
25- output=$(python duya.py 2>&1) # 捕获标准错误(可选,用于调试)
26-
27- # 设置输出变量(供后续步骤使用)
28- echo "result=$output" >> $GITHUB_OUTPUT
29-
30- # 将结果写入文件(双重备份)
31- echo "$output" > subscription.txt
32-
33- - name : Upload subscription file
34- uses : actions/upload-artifact@v4
35- with :
36- name : duya-subscription
37- path : subscription.txt
38- retention-days : 1 # 保留1天(避免占用存储空间)
1+ - name : Run duya.py script
2+ id : run-script
3+ run : |
4+ # 运行脚本并捕获输出(将换行符替换为空格)
5+ output=$(python duya.py 2>&1 | tr '\n' ' ') # 关键:去掉换行符
6+
7+ # 设置输出变量(确保单行格式)
8+ echo "result=$output" >> $GITHUB_OUTPUT
9+
10+ # 将结果写入文件(保留原始格式,不影响)
11+ echo "$output" > subscription.txt
You can’t perform that action at this time.
0 commit comments