GitHub 部署相关 trouble-shooting
Original...About 1 min
GitHub 部署相关 trouble-shooting
部署失败,提示无法写入
参考 https://zhuanlan.zhihu.com/p/598824876
需要给 write 权限
操作:Settings / Actions / General / Workflow permissions,选择 Read and write permissions。
跨仓库部署失败,提示无权限
[gh-pages (root-commit) 2fcb7c2] Initial gh-pages commit
/usr/bin/chmod -R +rw /home/runner/work/my-blog-private/my-blog-private/src/.vuepress/dist
/usr/bin/rsync -q -av --checksum --progress /home/runner/work/my-blog-private/my-blog-private/src/.vuepress/dist/. github-pages-deploy-action-temp-deployment-folder --delete --exclude CNAME --exclude .ssh --exclude .git --exclude .github
Checking if there are files to commit…
/usr/bin/git add --all .
/usr/bin/git checkout -b github-pages-deploy-action/yvl5selpu
Switched to a new branch 'github-pages-deploy-action/yvl5selpu'
/usr/bin/git commit -m Deploying to gh-pages from @ QuadnucYard/my-blog-private@9017cb2e03ada05bbb5720ad864587ebac41490d 🚀 --quiet --no-verify
Force-pushing changes...
/usr/bin/git push --force ***github.com/QuadnucYard/my-blog.git github-pages-deploy-action/yvl5selpu:gh-pages
remote: Permission to QuadnucYard/my-blog.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/QuadnucYard/my-blog.git/': The requested URL returned error: 403
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/yvl5selpu
Reset branch 'github-pages-deploy-action/yvl5selpu'
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Error: The deploy step encountered an error: The process '/usr/bin/git' failed with exit code 128 ❌
Notice: Deployment failed! ❌
错误信息比较多,关键一条是跨仓库部署时目标仓库拒绝访问。
根据 JamesIves/github-pages-deploy-action
的指示,在跨仓库时,需要在 with
中加上 token
项来说明 PAT,其值为源码仓库的一个 secret。
- name: 部署文档
uses: JamesIves/github-pages-deploy-action@v4
with:
repository-name: QuadnucYard/QuadnucYard.github.io
branch: gh-pages
folder: src/.vuepress/dist
token: ${{ secrets.TARGET_REPO_TOKEN }}
然后就成功了。
这里是部署到 <USER>.github.io
。如果是部署到 <USER>.github.io/<REPO>
还需要改 vuepress 的 base
。