Skip to content

Commit

Permalink
fix: cron中变量的默认值
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Aug 16, 2024
1 parent b9b72fc commit b2227b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron_bypassCF.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: bypassCF cron old
name: bypassCF cron

on:
schedule:
Expand Down
77 changes: 13 additions & 64 deletions .github/workflows/cron_read.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: bypassCF cron old
name: read cron old don't use

on:
schedule:
# 每天 UTC 时间 18:00 运行
- cron: "0 18 * * *"
workflow_dispatch: # 允许手动触发
# schedule:
# # 每天 UTC 时间 18:00 运行
# - cron: "0 18 * * *"
workflow_dispatch: # 添加这行以允许手动触发

jobs:
build:
Expand All @@ -13,70 +13,19 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [20.x] # 选择你需要的 Node.js 版本
env:
# 在作业级别设置环境变量
USERNAMES: ${{ secrets.USERNAMES }}
PASSWORDS: ${{ secrets.PASSWORDS }}

steps:
- uses: actions/checkout@v3 # 检出仓库

- 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
# Debug: 确认环境变量已加载
echo "Debug: USERNAMES = $USERNAMES"
echo "Debug: PASSWORDS = $PASSWORDS"
echo "Debug: WEBSITE = $WEBSITE"
# 如果 GitHub Secrets 中设置了环境变量,则覆盖默认值
if [ -n "${{ 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 }}" ]; then
echo "Using GitHub Secret for PASSWORDS"
echo "PASSWORDS=${{ secrets.PASSWORDS }}" >> $GITHUB_ENV
else
echo "PASSWORDS=${PASSWORDS}" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.WEBSITE }}" ]; then
echo "Using GitHub Secret for WEBSITE"
echo "WEBSITE=${{ secrets.WEBSITE }}" >> $GITHUB_ENV
else
echo "WEBSITE=${WEBSITE}" >> $GITHUB_ENV
fi
# Debug: 输出最终的环境变量值
echo "Final values in GITHUB_ENV:"
cat $GITHUB_ENV
shell: bash
run: npm install # 安装 package.json 中的依赖项
- name: Run a script
run: xvfb-run node bypasscf.js
run: node bypasscf.js # 替换为你想运行的脚本的实际名称

0 comments on commit b2227b6

Please sign in to comment.