当有人提出 PR 时,此工作流程会出错。它在问题部分工作得很好。
name: Greetings
on:
issues:
types:
- opened
pull_request:
types:
- opened
jobs:
Greetings:
runs-on: ubuntu-latest
steps:
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{ github.event_name }}" == "issues" ]]; then
gh issue comment ${{ github.event.issue.html_url }} --body "@${{ github.event.issue.user.login }}
Thank you for raising this issue! 🎉🙌
We truly appreciate your contribution to this project and will review the details shortly. 🛠️✨
We will get back to you soon!
Thank you for your patience! 🙏"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
gh pr comment ${{ github.event.pull_request.html_url }} --body "@${{ github.event.pull_request.user.login }}
Thank you for your Pull Request!
We truly appreciate your contribution! 🙌
We will review the changes and provide feedback or merge the PR soon. 🔍
Please stay tuned for updates! 🔔
🌟 Thank you for your efforts in improving the project! 🙏"
fi
我已授予工作流程读写权限。您可以在下面的屏幕截图中看到它:
我面临这个错误:
谁能帮我解决这个问题?
secrets.GITHUB_TOKEN
受设计限制,评论PR需要更多许可。
解决方案是创建一个具有所需权限的“创建个人访问令牌(PAT)”。
创建 PAT: 您的帐户设置 -> 开发者设置 -> 个人访问令牌 -> 生成具有存储库范围的新令牌。
将 PAT 添加到存储库:
仓库 -> 设置 -> 秘密和变量 -> 操作 -> 添加新秘密并为其命名(为了方便起见,我们假设 PAT_TOKEN)并粘贴您创建的 PAT。
更新操作以使用新的 PAT。