fix(build-bot): report job 加 GH_REPO;已合并 PR 改为编默认分支
- report job 不 checkout,gh 没有 git 上下文会报 'fatal: not a git repository' → 补 GH_REPO 环境变量 - 只有 state=open 的 PR 才编它的 head.sha; 已合并/已关闭的 PR 编译默认分支,避免编到过期代码 - 回执里提示「PR 已 merged,改为编译默认分支」
This commit is contained in:
1 parent
936ef8333e
commit
5b82a885f9
1 file changed
+11
-1
@@ -79,7 +79,15 @@ jobs:
|
||||
echo "is_pr=$IS_PR" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$IS_PR" = "true" ]; then
|
||||
REF=$(gh api "repos/${{ github.repository }}/pulls/${ISSUE_NUMBER}" --jq '.head.sha')
|
||||
# 只有「还开着」的 PR 才编它的 head;已合并/已关闭的 PR 编默认分支,
|
||||
# 否则会编到一份过期的代码。
|
||||
PR_STATE=$(gh api "repos/${{ github.repository }}/pulls/${ISSUE_NUMBER}" --jq '.state')
|
||||
if [ "$PR_STATE" = "open" ]; then
|
||||
REF=$(gh api "repos/${{ github.repository }}/pulls/${ISSUE_NUMBER}" --jq '.head.sha')
|
||||
else
|
||||
REF="${{ github.event.repository.default_branch }}"
|
||||
echo "PR 已 $PR_STATE,改为编译默认分支"
|
||||
fi
|
||||
else
|
||||
REF="${{ github.event.repository.default_branch }}"
|
||||
fi
|
||||
@@ -261,6 +269,8 @@ jobs:
|
||||
- name: 回帖结果
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# 本 job 不 checkout(省时间),gh 需要显式指定仓库
|
||||
GH_REPO: ${{ github.repository }}
|
||||
ISSUE: ${{ github.event.issue.number }}
|
||||
TARGET: ${{ needs.prepare.outputs.target }}
|
||||
REF: ${{ needs.prepare.outputs.ref }}
|
||||
|
||||
Reference in new issue
Block a user