Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/package-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Refresh Dependabot action bundle

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]

permissions:
contents: write

concurrency:
group: package-dependabot-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
package:
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: true
Comment on lines +20 to +23

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Isolate the write token from dependency execution

When a Dependabot update contains a compromised npm package or build tool, its lifecycle hooks or code loaded by yarn build execute after checkout has persisted a repository-wide contents: write credential. The checkout input documentation confirms that this credential enables subsequent scripts to run authenticated Git commands, so hostile dependency code could push or delete refs beyond the intended dist commit and bypass the branch/SHA restriction in the final command. Run installation and packaging in a read-only job, then pass the generated artifact to a separately isolated writer with narrowly scoped credentials.

Useful? React with 👍 / 👎.

- uses: actions/setup-node@v6
with:
node-version: '24.19.0'
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Commit updated action bundle
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
EXPECTED_SHA: ${{ github.event.pull_request.head.sha }}
run: |
if git diff --quiet -- dist; then
exit 0
fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -- dist
git commit -m 'chore: rebuild packaged action for dependency update'
git push origin "HEAD:refs/heads/$BRANCH" --force-with-lease="refs/heads/$BRANCH:$EXPECTED_SHA"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Trigger validation automatically for the rebuilt head

Whenever packaging changes dist, this push updates the PR using the persisted repository GITHUB_TOKEN; according to GitHub's workflow-trigger documentation, pull_request runs resulting from a PR update made with that token are created in an approval-required state. Consequently the new head does not automatically receive the independent CI, unit, and Jira E2E results—the earlier runs belong to the pre-generated head—so required checks can remain pending until a maintainer manually approves them. Use an authentication/dispatch design that starts validation for the generated commit without approval.

Useful? React with 👍 / 👎.

Loading