CI: only run slash-command dispatch job for real slash commands - #8280
CI: only run slash-command dispatch job for real slash commands#8280arash77 wants to merge 1 commit into
Conversation
|
Can you split the fixes for the two problems in separate PRs? We should definitely use only one method to find the PR. Good point.
IMO commits should only be allowed to be integrated via PRs. I think we enforce this at IUC. But yes .. maybe we should not restrict how people like to work .. or?
If this is a bug in the actions, then I would prefer to fix those .. or at least to report it there .. ? I also do not understand how this is related to "Push to the default branch aborts linting".
I do not understand this part.
Yes. This sounds right and as intended to me.
This contradicts the first sentence of the statement, or?
I do not understand this sentence. In summary. I'm fine with the changes wrt the slash command. For the other part I definitely agree that it would be better to use only one method to get the PR. Also we likely need to implement this on our own .. due to the node20 problem. But I'm not convinced yet with the analysis. |
6f958e6 to
67d543a
Compare
|
Split done. This PR is now I was wrong about one thing, and you were right to doubt it. I claimed the old lookup silently dropped the skip labels. It does not. if (context.eventName === 'pull_request') {
pullRequest = await fetchPRByNumber();
} else if (context.eventName === 'push' || context.eventName === 'workflow_run') {
pullRequest = await fetchPRBySha();
}So on That also answers your question about how it relates to "Push to the default branch aborts linting". It does not. Without that claim, #8281 is only:
I can also convert About the push branch. It is not about direct pushes. Those now just give no labels and run full checks instead of failing. It is there because a push to About the re-run sentence. Sorry, that was two ideas in one sentence. Old and new code both call the API, so nothing changed there. The re-run point was my reason for not switching to About the Thanks for checking the reasoning and not just the diff. Update: force-pushed a rewrite of
One question: with a missing PAT the run is now green with no feedback, instead of a red X. Prefer it to fail loudly? Then the guard goes away entirely. |
The job allocated a runner for every issue_comment in the org, nearly
all of which are ordinary comments. Gate the job on the command name
appearing in the comment body -- a superset of what the action acts on,
so dispatch behaviour is unchanged.
Also:
- hoist the existing repository_owner condition to job level, so forks
stop allocating a runner for a job that can never dispatch;
- guard the dispatch step on a non-empty PAT. secrets is not available
in an if condition but env is, and secrets is available in a job-level
env, so that mapping is the bridge -- no shell step needed;
- grant the job the minimal permissions it needs. Only the "eyes"
reaction uses GITHUB_TOKEN (reaction-token), via
reactions.createForIssueComment, so issues: write suffices. The
permission check, pull lookup and dispatch all authenticate with the
PAT, so permissions: {} would silently drop the reaction.
Scope note: the PAT guard does not fix the copy-of-this-CI case in
bgruening/galaxytools. A copy of this file keeps an owner check that
skips the whole job before the guard is reached. What it covers is PAT
loss or rotation within galaxyproject-owned repos.
Refs: bgruening/galaxytools#1944
67d543a to
053a3fb
Compare
FOR CONTRIBUTOR:
CI-only change. Refs bgruening/galaxytools#1944 (item 1). Split from #8281 at @bernt-matthias' request.
Main effect: stop allocating a runner for every issue comment.
on: issue_commentfires on every comment on every issue and PR in this repo, and each one previously started a runner to execute an action that immediately exits. The job is now gated on the command name appearing in the comment body. That is a strict superset of whatslash-command-dispatchacts on (it requires the command at the start of the first line), so dispatch behaviour, the reaction, and the permission-denied path are all unchanged.Also in this PR:
repository_ownercheck moves from the step to the job, so forks stop allocating a runner for a job that can never dispatch.Missing required input 'token'cannot fail the run.secretsis not available in anifcondition, butenvis, andsecretsis available in a job-levelenv— that mapping is the bridge, so no shell step is needed.permissions: issues: write. Only the 👀 reaction usesGITHUB_TOKEN(viareaction-token→reactions.createForIssueComment); the permission check, pull lookup and dispatch all authenticate with the PAT. Note that the temptingpermissions: {}would silently drop the reaction.Scope correction from the earlier revision of this PR: the PAT guard does not fix the copy-of-this-CI case in bgruening/galaxytools. A copy of this file carries an owner check that skips the whole job before the guard is ever reached. What the guard actually covers is PAT loss or rotation within galaxyproject-owned repos. Note it only tests for a non-empty value, so an expired or revoked PAT still reaches the action and still fails.
Where a PAT is set and someone types the command, nothing changes.
.github/**is inpr.yaml'spaths-ignore, so this PR does not trigger the tool CI.actionlintis clean.zizmornow reports only the pre-existingunpinned-useson the@v5tag, which is the convention in this repo (cf. b0bb570); theexcessive-permissionsfinding it previously reported on this file is resolved by thepermissionsblock.