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
生成新的token(带workflow权限)
配置action变量
修改actions/checkout@v3 token
- uses: actions/checkout@v3with:token: ${{ secrets.WORKFLOW_TOKEN }}
name: schedule tasks
run-name: run schedule taskson:schedule:- cron: '0 0 * * *'- cron: '0 10 * * *'jobs:build:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v3with:token: ${{ secrets.WORKFLOW_TOKEN }}- name: Run scheduleif: ${{ github.event_name == 'schedule' && github.event.schedule != '0 10 * * *' }}run: |cd runsh main.sh- name: Update scheduleif: ${{ 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.ymlgit 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 --rebasegit push