diff --git a/.github/workflows/cron_read.yaml b/.github/workflows/cron_read.yaml index aa3866cf..4d0aa3bf 100644 --- a/.github/workflows/cron_read.yaml +++ b/.github/workflows/cron_read.yaml @@ -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