错误:
! [remote rejected] main -> main (refusing to allow a GitHub App to create or update workflow `.github/workflows/docker.yml` without `workflows` permission)
经过一番研究,我了解到我需要授予它必要的权限。我不知道从哪里以及如何授予它许可。我也没有太多经验。
我应该如何修复这个错误?这是因为我强制对存储库进行更改,因为正常推送被拒绝。
我非常清楚我一开始就不应该使用
--force
。既然我需要推动他们,我就有义务这样做。我在推送之前从 main 中拉取,这会导致需要手动解决的冲突,而我不想这样做。代码:
name: Update Fork
on:
workflow_dispatch:
schedule:
- cron: '0 10 * * *' # runs every everyday at 10:00
jobs:
update_fork:
runs-on: ubuntu-latest
steps:
- name: Checkout Forked Repo
uses: actions/checkout@v2
with:
repository: username/repo_name
ref: main
- name: Setup Git
run: git config --global user.email ${{ secrets.EMAIL }} && git config --global user.name user_name
- name: Check for Upstream Changes
run: |
git remote add upstream https://github.com/upstream_user_name/upstream_repo
upstream_commit=$(git ls-remote --heads upstream | grep main | awk '{print $1}')
# forked_commit=$(git rev-list --max-count=1 HEAD)
forked_commit=$(git log -n 10 --pretty=%H)
# if git rev-list $forked_commit..HEAD | grep -q $upstream_commit; then
if echo "$forked_commits" | grep -q "$upstream_commit"; then
echo "No commits to be synced!"
else
git fetch upstream
git pull --rebase -X ours upstream main
git push -f origin main
echo "Rebase successful!"
fi
此代码未能推送提交后,我添加了以下代码:
with:
repository: username/repo_name
ref: main
repo-token: ${{ secrets.GITHUB_TOKEN }}
这也没有解决问题。我很确定这是错误的..
我不确定以上答案是否解决了问题。我遇到了类似的问题,发现这个有效: