Skip to content

Commit 212a4f5

Browse files
committed
fix(ci): Use correct context variable in github-script
In actions/github-script@v8, the GitHub context is available as the global variable 'context', not 'github.context'. The previous fix incorrectly used github.context which doesn't exist in the github-script environment, causing "Invalid GitHub context" errors on pull_request_target events. Also added defensive return statements after core.setFailed() calls. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com> Assisted-by: Claude-3.5-Sonnet (via Claude Code)
1 parent e4e992b commit 212a4f5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

.github/workflows/e2e.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ jobs:
8080
uses: actions/github-script@v8
8181
with:
8282
script: |
83-
if (!github || !github.context || !github.context.payload || !github.context.payload.pull_request) {
83+
if (!context || !context.payload || !context.payload.pull_request) {
8484
core.setFailed('Invalid GitHub context: missing required pull_request information');
8585
return;
8686
}
8787
8888
async function run() {
89-
const actor = github.context.payload.pull_request.user.login;
90-
const repoOwner = github.context.repo.owner;
91-
const repoName = github.context.repo.repo;
92-
const targetOrg = github.context.repo.owner;
89+
const actor = context.payload.pull_request.user.login;
90+
const repoOwner = context.repo.owner;
91+
const repoName = context.repo.repo;
92+
const targetOrg = context.repo.owner;
9393
9494
core.info(`🔍 Starting permission check for user: @${actor}`);
9595
core.info(`📋 Repository: ${repoOwner}/${repoName}`);
@@ -221,13 +221,15 @@ jobs:
221221
core.setFailed(
222222
`❌ Permission check failed. User @${actor} did not meet any required conditions (trusted bot, org member, or repo write access).`,
223223
);
224+
return;
224225
}
225226
} catch (error) {
226227
// This error means they are not even a collaborator.
227228
core.info(` ❌ Collaborator permission check failed: ${error.message}`);
228229
core.setFailed(
229230
`❌ Permission check failed. User @${actor} is not a collaborator on this repository and did not meet other conditions.`,
230231
);
232+
return;
231233
}
232234
}
233235

0 commit comments

Comments
 (0)