When you enable GitHub Actions, GitHub installs a GitHub App on your repository. The GITHUB_TOKEN secret is a GitHub App installation access token. You can use the installation access token to authenticate on behalf of the GitHub App installed on your repository. The token’s permissions are limited to the repository that contains your workflow.About the GITHUB_TOKEN secret
配置action变量

修改actions/checkout@v3 token
- uses: actions/checkout@v3
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
name: schedule tasks
run-name: run schedule tasks
on:
schedule:
- cron: '0 0 * * *'
- cron: '0 10 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
- name: Run schedule
if: ${{ github.event_name == 'schedule' && github.event.schedule != '0 10 * * *' }}
run: |
cd run
sh main.sh
- name: Update schedule
if: ${{ github.event_name == 'schedule' && github.event.schedule == '0 10 * * *' }}
run: |
hour=$(($RANDOM%5))
min=$(($RANDOM%59))
sed -i "0,/cron/{s/- cron: '.*\* \* \*'/- cron: '${min} ${hour} * * *'/}" .github/workflows/schedule-actions.yml
git config --global user.email ${{ secrets.GCON_USER_EMAIL }}
git config --global user.name ${{ secrets.GCON_USER_NAME }}
git add .
git commit -m "update schedule to: ${min} ${hour} * * *"
git pull --rebase
git push