在今年(2023)全新建立的專案,執行到 JamesIves/github-pages-deploy-action 步驟時會失敗,根據 log 可以得知是在 GitHub Actions 執行到 git push
時遇到 403 錯誤。
/usr/bin/git commit -m Deploying to page from @ ngseke/test@075776ff3f9a7b27bb5809efe605152205deabe5 🚀 –quiet –no-verify
/usr/bin/git push –force ***github.com/ngseke/test.git github-pages-deploy-action/8rb7mcfwb:page
remote: Permission to ngseke/test.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/ngseke/test.git/': The requested URL returned error: 403
這是 GitHub 在 2023 年 2 月的這個變動所導致的,原先 GITHUB_TOKEN
會一律預設得到 read/write 的權限,但後來改成了 read-only 才使得 git push
失敗,因此只需要手動調整權限即可。
現有專案則會維持原本的權限,不需要額外設定。
到 Repository → Settings 分頁 → 左側欄 Actions → General
Workflow permissions 區塊 → 選中 Read and write permissions → 點擊 Save
再次 Re-run workflow 應該就可以成功部署