Skip to content

ci(sbom): open PR for SBOM updates instead of pushing direct to protected branches#76

Merged
rubenvdlinde merged 1 commit intodevelopmentfrom
ci/sbom-pr-on-protected-branches
May 1, 2026
Merged

ci(sbom): open PR for SBOM updates instead of pushing direct to protected branches#76
rubenvdlinde merged 1 commit intodevelopmentfrom
ci/sbom-pr-on-protected-branches

Conversation

@rubenvdlinde
Copy link
Copy Markdown
Contributor

Summary

Unblocks the third red check on PR #72 (release: development → beta): `SBOM Generation & Validation`.

The current `Commit SBOM` step does `git push` unconditionally on every push trigger. On main / development / beta the org ruleset rejects that push and the workflow fails with:

```
remote: error: GH013: Repository rule violations found for refs/heads/development.
error: failed to push some refs to 'https://github.com/ConductionNL/mydash'
##[error]Process completed with exit code 1.
```

(Source: PR #72's failing run, job `SBOM Generation & Validation` in run `25190361610`.)

What changed

Split the post-build step by event/branch type:

Trigger Step Behaviour
`push` to `feature/`, `bugfix/`, `hotfix/**` Commit SBOM (unprotected branches) Direct commit + push — same as today
`push` to `main` / `development` / `beta` Open PR with SBOM update (protected branches) `peter-evans/create-pull-request@v6` opens or updates `chore/sbom-update-` with the regenerated `sbom.cdx.json`. A reviewer merges normally; the ruleset's review requirement is honoured.
`pull_request` Both steps skipped The SBOM is already validated by the scan steps above; merging the PR re-triggers this workflow on the target branch.

Also adds an explicit job-level `permissions:` block (`contents: write`, `pull-requests: write`) so the bot has the perms it needs without relying on the repo's default permission setting.

Test plan

  • YAML validated locally
  • Once merged, the next push to `development` triggers the workflow and either:
    • reports "No SBOM changes to commit" (when sbom is already in sync), or
    • opens `chore/sbom-update-development` with the regenerated `sbom.cdx.json`
  • Confirm PR Release: merge development into beta #72's `SBOM Generation & Validation` check goes green on its next run

The Commit SBOM step ran a direct `git push` on every push trigger.
On protected branches (main / development / beta) the org ruleset
rejects unbypassed pushes, so the workflow failed with `GH013:
Repository rule violations` — visible as the red `SBOM Generation &
Validation` check on every release PR.

Split the post-build step in two:

- Unprotected branches (feature/**, bugfix/**, hotfix/**) keep the
  fast direct-commit path — no protection, no friction.
- Protected branches use peter-evans/create-pull-request to open
  (or update) `chore/sbom-update-<branch>` with the regenerated
  `sbom.cdx.json`, base'd on the same branch. A reviewer merges as
  with any other PR, so the org ruleset's "1 review" requirement is
  honoured.
- pull_request events skip the commit step entirely. The SBOM is
  already validated by the preceding scan steps; once the PR merges,
  this same workflow re-runs against the target branch and goes down
  one of the two paths above.

Adds explicit job-level `permissions: contents: write,
pull-requests: write` so the bot can write commits / open PRs without
relying on whatever the repo's default permissions happen to be.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Quality Report — ConductionNL/mydash @ 7cd604a

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 100/100
npm ✅ 342/342
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-05-01 07:23 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde rubenvdlinde merged commit 6945bf1 into development May 1, 2026
22 of 26 checks passed
@rubenvdlinde rubenvdlinde deleted the ci/sbom-pr-on-protected-branches branch May 1, 2026 07:58
rubenvdlinde added a commit that referenced this pull request May 3, 2026
The Commit SBOM step ran a direct `git push` on every push trigger.
On protected branches (main / development / beta) the org ruleset
rejects unbypassed pushes, so the workflow failed with `GH013:
Repository rule violations` — visible as the red `SBOM Generation &
Validation` check on every release PR.

Split the post-build step in two:

- Unprotected branches (feature/**, bugfix/**, hotfix/**) keep the
  fast direct-commit path — no protection, no friction.
- Protected branches use peter-evans/create-pull-request to open
  (or update) `chore/sbom-update-<branch>` with the regenerated
  `sbom.cdx.json`, base'd on the same branch. A reviewer merges as
  with any other PR, so the org ruleset's "1 review" requirement is
  honoured.
- pull_request events skip the commit step entirely. The SBOM is
  already validated by the preceding scan steps; once the PR merges,
  this same workflow re-runs against the target branch and goes down
  one of the two paths above.

Adds explicit job-level `permissions: contents: write,
pull-requests: write` so the bot can write commits / open PRs without
relying on whatever the repo's default permissions happen to be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant