|
15 | 15 | dependabot: |
16 | 16 | if: github.event.pull_request.user.login == 'dependabot[bot]' |
17 | 17 | runs-on: ubuntu-latest |
| 18 | + # Keep this job as a stable, always-green check on Dependabot PRs, even when the workflow is |
| 19 | + # re-triggered by an automation commit (e.g., vendoring). Sensitive operations (OIDC token mint, |
| 20 | + # approving, enabling auto-merge) are delegated to `dependabot-automation` below. |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + steps: |
| 24 | + - name: Status |
| 25 | + run: | |
| 26 | + echo "Dependabot PR detected." |
| 27 | + if [ "${{ github.actor }}" = "dependabot[bot]" ]; then |
| 28 | + echo "Automation steps will run in the 'dependabot-automation' job." |
| 29 | + else |
| 30 | + echo "Skipping automation: workflow actor is '${{ github.actor }}'." |
| 31 | + fi |
| 32 | +
|
| 33 | + dependabot-automation: |
| 34 | + # Only run automation on the initial Dependabot-triggered run. If an automation commit is pushed |
| 35 | + # (e.g. vendor output), GitHub re-triggers this workflow with `github.actor == 'dd-octo-sts[bot]'`. |
| 36 | + # We intentionally avoid minting tokens / approving / enabling auto-merge on that follow-up run. |
| 37 | + if: github.event.pull_request.user.login == 'dependabot[bot]' && github.actor == 'dependabot[bot]' |
| 38 | + runs-on: ubuntu-latest |
18 | 39 | permissions: |
19 | 40 | id-token: write |
20 | 41 | steps: |
@@ -150,6 +171,11 @@ jobs: |
150 | 171 | with: |
151 | 172 | scope: DataDog/dd-trace-js |
152 | 173 | policy: dependabot-automation |
| 174 | + - name: Dependabot metadata |
| 175 | + id: metadata |
| 176 | + uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # 2.5.0 |
| 177 | + with: |
| 178 | + github-token: "${{ steps.octo-sts.outputs.token }}" |
153 | 179 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
154 | 180 | with: |
155 | 181 | token: ${{ steps.octo-sts.outputs.token }} |
@@ -209,6 +235,22 @@ jobs: |
209 | 235 | auth_header="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$DD_OCTO_STS_TOKEN" | base64 | tr -d '\n')" |
210 | 236 | git -c "http.https://github.com/.extraheader=$auth_header" push origin "HEAD:$TARGET_BRANCH" |
211 | 237 |
|
| 238 | + # If branch protection is configured to dismiss stale approvals when new commits are pushed, |
| 239 | + # the vendoring commit will invalidate the earlier approval. Re-approve and (re-)enable |
| 240 | + # auto-merge after pushing so Dependabot PRs can still merge automatically. |
| 241 | + - name: Approve a PR (after vendoring commit) |
| 242 | + if: contains(fromJSON(env.GROUPS), steps.metadata.outputs.dependency-group) |
| 243 | + run: gh pr review --approve "$PR_URL" |
| 244 | + env: |
| 245 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 246 | + GH_TOKEN: ${{ steps.octo-sts.outputs.token }} |
| 247 | + - name: Enable auto-merge for Dependabot PRs (after vendoring commit) |
| 248 | + if: contains(fromJSON(env.GROUPS), steps.metadata.outputs.dependency-group) |
| 249 | + run: gh pr merge --auto --squash "$PR_URL" |
| 250 | + env: |
| 251 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 252 | + GH_TOKEN: ${{ steps.octo-sts.outputs.token }} |
| 253 | + |
212 | 254 | vendor-validate: |
213 | 255 | # Run validation after the generated vendor patch has been pushed, to ensure the PR contains |
214 | 256 | # the committed `vendor/dist/*` outputs. This runs inside the same workflow as the push, so it |
|
0 commit comments