Skip to content

Commit a5cc4f9

Browse files
BridgeARsabrenner
authored andcommitted
ci: fix vendored dependabot PRs (#7306)
The main issue is AFAIK the Node.js version being used. This is now aligned with the installment of the bundle job. That is done in a secure way where we use least privileges possible. It also fixes a version for the action.
1 parent 9bdeca3 commit a5cc4f9

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

.github/workflows/dependabot-automation.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
pull_request:
55
types:
66
- opened
7+
- reopened
78
- synchronize
89

910
env:
11+
# Add Groups here to enable auto-merge for Dependabot PRs
1012
GROUPS: '["dev-minor-and-patch-dependencies", "gh-actions-packages", "test-versions"]'
1113

1214
jobs:
@@ -26,15 +28,15 @@ jobs:
2628
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # 2.5.0
2729
with:
2830
github-token: "${{ steps.octo-sts.outputs.token }}"
29-
- name: Enable auto-merge for Dependabot PRs
31+
- name: Approve a PR
3032
if: contains(fromJSON(env.GROUPS), steps.metadata.outputs.dependency-group)
31-
run: gh pr merge --auto --squash "$PR_URL"
33+
run: gh pr review --approve "$PR_URL"
3234
env:
3335
PR_URL: ${{ github.event.pull_request.html_url }}
3436
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
35-
- name: Approve a PR
37+
- name: Enable auto-merge for Dependabot PRs
3638
if: contains(fromJSON(env.GROUPS), steps.metadata.outputs.dependency-group)
37-
run: gh pr review --approve "$PR_URL"
39+
run: gh pr merge --auto --squash "$PR_URL"
3840
env:
3941
PR_URL: ${{ github.event.pull_request.html_url }}
4042
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
@@ -68,18 +70,25 @@ jobs:
6870
ref: ${{ github.event.pull_request.head.sha }}
6971
fetch-depth: 1
7072
persist-credentials: false
73+
- name: Restore trusted Node setup actions
74+
if: steps.ctx.outputs.is_vendor_group == 'true'
75+
run: |
76+
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
77+
git checkout "${{ github.event.pull_request.base.sha }}" -- .github/actions/node
7178
- name: Restore trusted vendoring scripts
7279
if: steps.ctx.outputs.is_vendor_group == 'true'
7380
run: |
7481
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
7582
git checkout "${{ github.event.pull_request.base.sha }}" -- vendor/rspack.js vendor/rspack.config.js
83+
- uses: ./.github/actions/node/active-lts
84+
if: steps.ctx.outputs.is_vendor_group == 'true'
7685
- name: Install vendoring deps (no lifecycle scripts)
7786
if: steps.ctx.outputs.is_vendor_group == 'true'
7887
run: yarn --ignore-scripts --frozen-lockfile --non-interactive
7988
working-directory: ./vendor
8089
- name: Build vendored bundles (trusted script)
8190
if: steps.ctx.outputs.is_vendor_group == 'true'
82-
run: node rspack
91+
run: node ./rspack.js
8392
working-directory: ./vendor
8493
- name: Create patch (restricted paths only)
8594
id: diff
@@ -119,7 +128,7 @@ jobs:
119128
120129
git diff --binary --no-color > vendor.patch
121130
echo "has_changes=true" >> $GITHUB_OUTPUT
122-
- uses: actions/upload-artifact@ea165f8a6f3f9f5b76b7b70ee0fdd3b5d7d3b6a2 # v4.6.2
131+
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
123132
if: steps.diff.outputs.has_changes == 'true'
124133
with:
125134
name: vendor-patch
@@ -134,13 +143,20 @@ jobs:
134143
# It only applies the vetted patch artifact and pushes a single commit.
135144
permissions:
136145
contents: write
146+
id-token: write
137147
steps:
148+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
149+
id: octo-sts
150+
with:
151+
scope: DataDog/dd-trace-js
152+
policy: dependabot-automation
138153
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
139154
with:
155+
token: ${{ steps.octo-sts.outputs.token }}
140156
repository: ${{ github.event.pull_request.head.repo.full_name }}
141157
ref: ${{ github.event.pull_request.head.sha }}
142158
persist-credentials: false
143-
- uses: actions/download-artifact@65c5b1180b77f85ea54a67a3d1f4d5f1e2e50bd8 # v4.2.0
159+
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
144160
with:
145161
name: vendor-patch
146162
- name: Apply patch
@@ -182,6 +198,8 @@ jobs:
182198
echo "commits=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
183199
- name: Push commit
184200
uses: DataDog/commit-headless@583489e08d78037e7fa256c14adf998d5463f6a0 # action/v2.0.2
201+
env:
202+
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
185203
with:
186204
branch: ${{ github.event.pull_request.head.ref }}
187205
command: push

0 commit comments

Comments
 (0)