Skip to content

Commit 067645d

Browse files
committed
Fix assignee/reviewer requests in push_screenshots workflow
"gh pr edit --add-assignee/--add-reviewer" always fetches editable PR options (labels/projects/teams) via a GraphQL query that requires the "read:org" token scope. ERTOMATIC_ERT_TESTDATA_TOKEN only has the "repo" scope, so the command failed unconditionally, regardless of whether the PR author actually had write access to ert-testdata. Replace it with direct REST API calls (assignees and requested_reviewers endpoints), which only need the "repo" scope. On failure, surface the real exit code and error/response body instead of assuming "insufficient access", since the failure could have other causes.
1 parent c5bee30 commit 067645d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/push_screenshots.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,21 @@ jobs:
9999
--head "$BRANCH" \
100100
--title "Update screenshots for ${ERT_PR_TITLE} (equinor/ert#${PR_NUMBER})" \
101101
--body "Automatically updated screenshot baselines triggered by https://github.com/equinor/ert/pull/${PR_NUMBER} by @${ERT_PR_AUTHOR}")
102-
gh pr edit "$PR_URL" --repo equinor/ert-testdata --add-assignee "${ERT_PR_AUTHOR}" --add-reviewer "${ERT_PR_AUTHOR}" \
103-
|| echo "::warning::Could not assign/request review from @${ERT_PR_AUTHOR} on ert-testdata (insufficient access)"
102+
TESTDATA_PR_NUMBER="${PR_URL##*/}"
103+
set +e
104+
ASSIGNEE_ERR=$(gh api --method POST "repos/equinor/ert-testdata/issues/${TESTDATA_PR_NUMBER}/assignees" \
105+
-f "assignees[]=${ERT_PR_AUTHOR}" 2>&1 > /dev/null)
106+
ASSIGNEE_STATUS=$?
107+
REVIEWER_ERR=$(gh api --method POST "repos/equinor/ert-testdata/pulls/${TESTDATA_PR_NUMBER}/requested_reviewers" \
108+
-f "reviewers[]=${ERT_PR_AUTHOR}" 2>&1 > /dev/null)
109+
REVIEWER_STATUS=$?
110+
set -e
111+
if [ "$ASSIGNEE_STATUS" -ne 0 ]; then
112+
echo "::warning::Could not assign @${ERT_PR_AUTHOR} on ert-testdata (exit code ${ASSIGNEE_STATUS}): ${ASSIGNEE_ERR}"
113+
fi
114+
if [ "$REVIEWER_STATUS" -ne 0 ]; then
115+
echo "::warning::Could not request review from @${ERT_PR_AUTHOR} on ert-testdata (exit code ${REVIEWER_STATUS}): ${REVIEWER_ERR}"
116+
fi
104117
if [ "${PR_NUMBER}" != "0" ]; then
105118
gh pr comment "${PR_NUMBER}" \
106119
--repo equinor/ert \

0 commit comments

Comments
 (0)