Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ff5fd7

Browse files
committed
refactor: align workflow structure with triage pattern
- Add comprehensive 'Determine Inputs' step matching triage workflow- Extract GitHub user ID lookup to separate step- Update all step references to use determine-inputs outputs- Fix heredoc formatting to properly handle backticks and variable expansion- Maintain PR comment posting flow (initial + update)
1 parentc20d661 commit2ff5fd7

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

‎.github/workflows/documentation-check.yaml‎

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,43 @@ jobs:
2727
actions:write
2828

2929
steps:
30-
-name:Determine PR Number
31-
id:determine-pr
30+
-name:Determine Inputs
31+
id:determine-inputs
32+
if:always()
3233
env:
34+
GITHUB_ACTOR:${{ github.actor }}
3335
GITHUB_EVENT_NAME:${{ github.event_name }}
3436
GITHUB_EVENT_PR_NUMBER:${{ github.event.pull_request.number }}
37+
GITHUB_EVENT_USER_ID:${{ github.event.sender.id }}
38+
GITHUB_EVENT_USER_LOGIN:${{ github.event.sender.login }}
3539
INPUTS_PR_NUMBER:${{ inputs.pr_number }}
40+
GH_TOKEN:${{ github.token }}
3641
run:|
42+
# For workflow_dispatch, use the actor who triggered it
43+
# For pull_request events, use the PR author
3744
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
45+
if ! GITHUB_USER_ID=$(gh api "users/${GITHUB_ACTOR}" --jq '.id'); then
46+
echo "::error::Failed to get GitHub user ID for actor ${GITHUB_ACTOR}"
47+
exit 1
48+
fi
49+
echo "Using workflow_dispatch actor: ${GITHUB_ACTOR} (ID: ${GITHUB_USER_ID})"
50+
echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}"
51+
echo "github_username=${GITHUB_ACTOR}" >> "${GITHUB_OUTPUT}"
52+
53+
echo "Using PR number: ${INPUTS_PR_NUMBER}"
3854
echo "pr_number=${INPUTS_PR_NUMBER}" >> "${GITHUB_OUTPUT}"
55+
56+
exit 0
3957
elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
58+
GITHUB_USER_ID=${GITHUB_EVENT_USER_ID}
59+
echo "Using PR author: ${GITHUB_EVENT_USER_LOGIN} (ID: ${GITHUB_USER_ID})"
60+
echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}"
61+
echo "github_username=${GITHUB_EVENT_USER_LOGIN}" >> "${GITHUB_OUTPUT}"
62+
63+
echo "Using PR number: ${GITHUB_EVENT_PR_NUMBER}"
4064
echo "pr_number=${GITHUB_EVENT_PR_NUMBER}" >> "${GITHUB_OUTPUT}"
65+
66+
exit 0
4167
else
4268
echo "::error::Unsupported event type: ${GITHUB_EVENT_NAME}"
4369
exit 1
@@ -47,19 +73,21 @@ jobs:
4773
env:
4874
GITHUB_REPOSITORY:${{ github.repository }}
4975
GH_TOKEN:${{ github.token }}
50-
GITHUB_ACTOR:${{ github.actor }}
76+
GITHUB_USERNAME:${{ steps.determine-inputs.outputs.github_username }}
77+
GITHUB_USER_ID:${{ steps.determine-inputs.outputs.github_user_id }}
5178
run:|
52-
can_push="$(gh api "/repos/${GITHUB_REPOSITORY}/collaborators/${GITHUB_ACTOR}/permission" --jq '.user.permissions.push')"
79+
# Query the actor's permission on this repo
80+
can_push="$(gh api "/repos/${GITHUB_REPOSITORY}/collaborators/${GITHUB_USERNAME}/permission" --jq '.user.permissions.push')"
5381
if [[ "${can_push}" != "true" ]]; then
54-
echo "::error title=Access Denied::${GITHUB_ACTOR} does not have push access to ${GITHUB_REPOSITORY}"
82+
echo "::error title=Access Denied::${GITHUB_USERNAME} does not have push access to ${GITHUB_REPOSITORY}"
5583
exit 1
5684
fi
5785
5886
-name:Post initial comment
5987
id:post-comment
6088
env:
6189
GH_TOKEN:${{ github.token }}
62-
PR_NUMBER:${{ steps.determine-pr.outputs.pr_number }}
90+
PR_NUMBER:${{ steps.determine-inputs.outputs.pr_number }}
6391
GITHUB_REPOSITORY:${{ github.repository }}
6492
RUN_ID:${{ github.run_id }}
6593
run:|
@@ -97,10 +125,11 @@ jobs:
97125
env:
98126
CODER_SESSION_TOKEN:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
99127
GH_TOKEN:${{ github.token }}
100-
GITHUB_ACTOR:${{github.actor }}
128+
GITHUB_USER_ID:${{steps.determine-inputs.outputs.github_user_id }}
101129
run:|
102-
GITHUB_USER_ID=$(gh api "users/${GITHUB_ACTOR}" --jq '.id')
103-
user_json=$(coder users list --github-user-id="${GITHUB_USER_ID}" --output=json)
130+
user_json=$(
131+
coder users list --github-user-id="${GITHUB_USER_ID}" --output=json
132+
)
104133
coder_username=$(jq -r 'first | .username' <<< "$user_json")
105134
[[ -z "${coder_username}" || "${coder_username}" == "null" ]] && echo "No Coder user with GitHub user ID ${GITHUB_USER_ID} found" && exit 1
106135
echo "coder_username=${coder_username}" >> "${GITHUB_OUTPUT}"
@@ -117,7 +146,7 @@ jobs:
117146
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
118147
GH_TOKEN:${{ github.token }}
119148
GITHUB_REPOSITORY:${{ github.repository }}
120-
PR_NUMBER:${{ steps.determine-pr.outputs.pr_number }}
149+
PR_NUMBER:${{ steps.determine-inputs.outputs.pr_number }}
121150
RUN_ID:${{ github.run_id }}
122151
TEMPLATE_NAME:"traiage"
123152
TEMPLATE_PRESET:"Default"
@@ -135,7 +164,7 @@ jobs:
135164
pr_diff=$(gh pr diff "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}")
136165
137166
# Build comprehensive prompt
138-
PROMPT=$(cat <<EOF
167+
PROMPT=$(cat <<'EOF'
139168
Analyze PR ${pr_url} for documentation updates.
140169

141170
## Task Description
@@ -159,9 +188,9 @@ ${pr_body}
159188
${files_changed}
160189

161190
**Code Diff**:
162-
\`\`\`diff
191+
```diff
163192
${pr_diff}
164-
\`\`\`
193+
```
165194

166195
## Output Format
167196
Please provide your analysis in the following format:
@@ -183,6 +212,11 @@ Please provide your analysis in the following format:
183212
Be specific and provide file paths and section references where applicable.
184213
EOF
185214
)
215+
# Expand variables in the prompt
216+
PROMPT=$(eval "cat <<EOF
217+
${PROMPT}
218+
EOF
219+
")
186220
export PROMPT
187221
188222
export TASK_NAME="doccheck-pr-${PR_NUMBER}-${RUN_ID}"
@@ -213,7 +247,7 @@ EOF
213247
-name:Update PR comment with results
214248
env:
215249
GH_TOKEN:${{ github.token }}
216-
PR_NUMBER:${{ steps.determine-pr.outputs.pr_number }}
250+
PR_NUMBER:${{ steps.determine-inputs.outputs.pr_number }}
217251
GITHUB_REPOSITORY:${{ github.repository }}
218252
COMMENT_ID:${{ steps.post-comment.outputs.comment_id }}
219253
TASK_NAME:${{ steps.create-task.outputs.TASK_NAME }}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp