fix(ci): degrade gracefully when Actions may not open PRs - #1462
fix(ci): degrade gracefully when Actions may not open PRs#1462Jayanth Reddy Bujula (jbujula) wants to merge 1 commit into
Conversation
The first run of the weekly refresh (#1441) did all of its real work and then failed on the last step: pull request create failed: GraphQL: GitHub Actions is not permitted to create or approve pull requests (createPullRequest) This is the org/repo policy "Allow GitHub Actions to create and approve pull requests", not a workflow bug. Every earlier step succeeded and the branch was pushed, so the refresh itself was fine -- only PR creation was refused. Left as-is, the weekly job goes red every week for a reason that cannot be fixed from inside the workflow, which just teaches people to ignore it. Now the step: - prints the underlying gh error either way, - on that specific policy error, emits a ::warning:: and writes a job summary containing a prefilled compare link plus the PR body, then exits 0 (the branch is pushed and green, so the work is recoverable in one click), - on any other error, still fails the run. If an admin enables the setting, no further change is needed and future runs open their own PRs. Verified with a stubbed gh reproducing the exact stderr: - policy error -> warning + summary written, exit 0 - unrelated error -> exit 1 (not swallowed) - yaml parses; bash -n clean on the extracted step. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6ac571cd-d84e-4b40-805a-e316a62ed292
|
This is no longer hypothetical - the failure this PR fixes happened again today. The weekly cron ( So the repo is now accumulating one dead branch per week, per repo, each with a red X on a job nobody can fix from the workflow:
Both contain real, green, useful work. The 0814 one is #1461. Still merges cleanlyRe-checked against current To restate the behavior, since it is the part worth reviewing carefully:
The If an admin instead enables Settings > Actions > General > "Allow GitHub Actions to create and approve pull requests", this code never runs and future weeks open their own PRs. Both paths are fine; this just stops the weekly red X and the silent branch pile-up in the meantime. |
Follow-up to #1441, found by actually running the new workflow instead of assuming it worked.
Run: https://github.com/microsoft/powerplatform-build-tools/actions/runs/31760462499
What happened
Every meaningful step passed -
npm ci,npm update,audit-overrides.js, andnpm run ci(build + test) - and the branch was pushed. Then the final step failed:That is the repo/org policy Settings > Actions > General > "Allow GitHub Actions to create and approve pull requests", which is disabled here. It is not something the workflow can fix, and no token change helps - it applies to
GITHUB_TOKEN-driven Actions runs regardless ofpermissions:.The run was still valuable: I opened its output by hand as #1461, which upgrades
nanoid3.3.17 -> 3.3.18, clearing GHSA-2v37-7h3g-55p8 (HIGH). That is the advisory I had documented on #1433, #1440 and #506 as "not fixable yet" because3.3.18was not mirrored onpackagefeedproxy.microsoft.io. The mirror synced, and the automation caught it on its first run with zero human input - which is precisely the Dependabot blind spot (overrides-pinned transitives) this was built for.The change
Failing the whole run for a policy the workflow cannot satisfy would put a red X on the weekly job every week, which reliably trains people to stop looking at it. But silently passing would hide real breakage. So the step now distinguishes the two:
::warning::+ job summary with a prefilled compare link and the full PR body, exit 0The underlying
gherror is printed in both cases. Because the branch is already pushed and green at that point, the work is recoverable in one click from the summary.If an admin enables the setting, nothing here needs to change - future runs will simply open their own PRs and never hit the fallback.
Verification
Tested with a stubbed
ghreproducing the exact stderr:some other unrelated API error) -> exit 1, fallback not triggered, so genuine failures are not maskedyaml.loadparses the workflow;bash -nclean on the extracted step script