各位 v 友好,我最近在学习 github actions, 但是不清楚为啥会在自动 push 的时候报错~ 就是 push 到当前 repo 的 main 分支的时候报错了 我也搜索了相关的 issue ,但是还是没法解决: https://github.com/ad-m/github-push-action/issues/96
特来求助各位呜呜呜
我的报错信息是:
Push to branch main
remote: Permission to ... denied to github-actions[bot].
fatal: unable to access '...': The requested URL returned error: 403
Error: Invalid exit code: 128
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:29:21)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
  code: 128
}
Error: Invalid exit code: 128
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:29:21)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
配置文件如下:
name: learn
env:
  PYTHON_VERSION: '3.8'               # set this to the Python version to use
on:
  issues:
    types:
      - labeled
jobs:
  learning:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - uses: actions/checkout@v2
        with:
          persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
          fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
	  
      ...
          
      - name: Commit files
        run: |
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          git commit -m "Add changes" -a
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
|  |      1imzcg2      2022-04-26 19:31:51 +08:00 via Android GITHUB_TOKEN ,你配置了吗,不会配百度啊 | 
|  |      2Doragd OP @imzcg2 我以为这个 GITHUB_TOKEN 是一个上下文变量来着呜呜呜,我懂了,是要去 secrets 里面添加是吧 | 
|  |      3ch2      2022-04-26 19:36:33 +08:00 试试用这个,首先生成一个 token 填到 settings->secrets 里,取名为 action_token - name: GitHub push run: | git config --global user.email "[email protected]" git config --global user.name "js-deliver" git config --global github.user js-deliver git config --global github.token $GITHUB_TOKEN git remote add publish https://你的用户名:[email protected]/你的用户名 /你的仓库名 /.git git checkout --orphan publish git commit -m "Auto commit version $version" git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all git push --force https://你的用户名:[email protected]/你的用户名 /你的仓库名 /.git publish:main env: GITHUB_TOKEN: ${{ secrets.action_token }} | 
|  |      5Doragd OP @imzcg2 谢谢您!!我现在明白了,之前确实自己没有去百度~用的谷歌,自己英文比较菜,没有很好地描述好问题,可能就没检索到,谢谢! | 
|  |      7Doragd OP | 
|  |      8AoEiuV020CN      2022-04-26 19:55:30 +08:00 via Android GITHUB_TOKEN 是有自动创建的,但有些限制,比如无法修改 workflows 相关,或者是有其他限制触发了, | 
|  |      9Doragd OP @AoEiuV020CN 谢谢您回复,我就是修改了 repo 的一些文件,然后 commit ,然后想 push 到这个 repo 来应用更改~这样也没有权限吗呜呜呜 | 
|  |      10Doragd OP @AoEiuV020CN @ch2 @imzcg2 谢谢大家的帮忙,我发现是我自己忘记把 contents 的 permission 设置为 write 了~呜呜呜真抱歉给大家造成麻烦~(当然 GITHUB_TOKEN 确实是不用配置的~TUT | 
|  |      11imzcg2      2022-04-26 20:15:05 +08:00 via Android |