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 3b044c1 commit 4cc640a
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/cron_read.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,54 @@ jobs:
sudo apt install -y xvfb
- name: Load environment variables
id: load-env
run: |
# 加载 .env 文件中的默认值
echo "Debug: Checking if .env file exists..."
# 检查 .env 文件是否存在
if [ -f .env ]; then
echo "Loading environment variables from .env file"
export $(grep -v '^#' .env | xargs)
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
# Debug: 输出 WEBSITE 的值
echo "Debug: Checking if GitHub Secret 'WEBSITE' is set..."
if [ -n "${{ secrets.WEBSITE }}" ]; then
echo "Debug: GitHub Secret 'WEBSITE' is set, using it."
echo "Using GitHub Secret for WEBSITE"
echo "WEBSITE=${{ secrets.WEBSITE }}" >> $GITHUB_ENV
else
echo "Debug: GitHub Secret 'WEBSITE' is not set, using value from environment or .env file."
echo "WEBSITE=${WEBSITE}" >> $GITHUB_ENV
fi
# Debug: 输出最后设置的 WEBSITE 值
echo "Debug: Final WEBSITE value is set to $(cat $GITHUB_ENV | grep WEBSITE)"
# Debug: 输出最终的环境变量值
echo "Final values in GITHUB_ENV:"
cat $GITHUB_ENV
shell: bash
- name: Run a script
run: xvfb-run node bypasscf.js

0 comments on commit 4cc640a

Please sign in to comment.