Skip to content

Commit

Permalink
chore: ...
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Aug 16, 2024
1 parent 5258ebd commit efe4ffb
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/cron_bypassCF.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: bypassCF cron (使用这个)
# GitHub.secrets优先级最高,即使没有设置对应的变量,它也会读取,这时变量为空值,导致报错,.env读取的变量无法覆盖这个值,使用了${PASSWORD_ESCAPED//\#/\\#}来对#转义
# GitHub.secrets优先级最高,即使没有设置对应的变量,它也会读取,这时变量为空值,导致报错,.env读取的变量无法覆盖这个值,使用了${PASSWORD_ESCAPED//\#/\\#}来对#转义,需要两个\,但是我直接在env文件使用这种方法是不行的,GitHub action是有效
on:
schedule:
# 每天 UTC 时间 18:00 运行
Expand All @@ -14,6 +14,10 @@ jobs:
strategy:
matrix:
node-version: [20.x]
env:
# 在作业级别设置环境变量
USERNAMES: ${{ secrets.USERNAMES }}
PASSWORDS: ${{ secrets.PASSWORDS }}

steps:
- uses: actions/checkout@v3 # 检出仓库
Expand Down Expand Up @@ -46,23 +50,6 @@ jobs:
echo ".env file not found. Skipping loading."
fi
# 如果 GitHub Secrets 中设置了环境变量,则覆盖默认值
if [ -n "${{ secrets.USERNAMES }}" ] && [ ! -z "${{ 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 }}" ] && [ ! -z "${{ secrets.PASSWORDS }}" ]; then
echo "Using GitHub Secret for PASSWORDS"
PASSWORD_ESCAPED="${{ secrets.PASSWORDS }}" && PASSWORD_ESCAPED=${PASSWORD_ESCAPED//\#/\\#}
echo "PASSWORDS=$PASSWORD_ESCAPED" >> $GITHUB_ENV
else
PASSWORD_ESCAPED="${PASSWORDS}" && PASSWORD_ESCAPED=${PASSWORD_ESCAPED//\#/\\#}
echo "PASSWORDS=$PASSWORD_ESCAPED" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.WEBSITE }}" ] && [ ! -z "${{ secrets.WEBSITE }}" ]; then
echo "Using GitHub Secret for WEBSITE"
echo "WEBSITE=${{ secrets.WEBSITE }}" >> $GITHUB_ENV
Expand Down

0 comments on commit efe4ffb

Please sign in to comment.