Skip to content

Commit e8a87dc

Browse files
authored
Automatically update Dependabot pull requests (#3064)
This updates the "update PR" workflow to trigger for Dependabot PRs automatically.
1 parent 58f0079 commit e8a87dc

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ jobs:
2020
run: ${{ steps.download-actionlint.outputs.executable }} -color
2121
shell: bash
2222

23+
update-pull-request:
24+
name: Update pull request
25+
needs: check-workflows
26+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' }}
27+
uses: ./.github/workflows/update-pull-request.yml
28+
with:
29+
dependabot: true
30+
secrets:
31+
PULL_REQUEST_UPDATE_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
32+
2333
lint-build-test:
2434
name: Build, lint, and test
2535
needs: check-workflows

.github/workflows/update-pull-request.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ on:
44
issue_comment:
55
types:
66
- created
7+
workflow_call:
8+
secrets:
9+
PULL_REQUEST_UPDATE_TOKEN:
10+
required: true
11+
inputs:
12+
dependabot:
13+
type: boolean
14+
required: false
15+
default: false
716

817
jobs:
918
is-fork-pull-request:
@@ -24,9 +33,10 @@ jobs:
2433
react-to-comment:
2534
name: React to the comment
2635
runs-on: ubuntu-latest
27-
needs: is-fork-pull-request
36+
needs:
37+
- is-fork-pull-request
2838
# Early exit if this is a fork, since later steps are skipped for forks.
29-
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }}
39+
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' && inputs.dependabot == false }}
3040
steps:
3141
- name: Checkout repository
3242
uses: actions/checkout@v4
@@ -46,7 +56,8 @@ jobs:
4656
prepare:
4757
name: Prepare dependencies
4858
runs-on: ubuntu-latest
49-
needs: is-fork-pull-request
59+
needs:
60+
- is-fork-pull-request
5061
# Early exit if this is a fork, since later steps are skipped for forks.
5162
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }}
5263
outputs:
@@ -203,10 +214,13 @@ jobs:
203214
path: yarn.lock
204215
key: cache-yarn-lock-${{ needs.prepare.outputs.COMMIT_SHA }}
205216
fail-on-cache-miss: true
217+
- name: Set commit prefix
218+
if: ${{ inputs.dependabot == true }}
219+
run: echo "COMMIT_PREFIX='[dependabot skip] '" >> "$GITHUB_ENV"
206220
- name: Commit yarn.lock
207221
run: |
208222
git add yarn.lock
209-
git commit -m "Deduplicate yarn.lock" || true
223+
git commit -m "${COMMIT_PREFIX}Deduplicate yarn.lock" || true
210224
- name: Restore LavaMoat policies
211225
uses: actions/cache/restore@v4
212226
with:
@@ -216,7 +230,7 @@ jobs:
216230
- name: Commit LavaMoat policies
217231
run: |
218232
git add packages/snaps-execution-environments/lavamoat
219-
git commit -m "Update LavaMoat policies" || true
233+
git commit -m "${COMMIT_PREFIX}Update LavaMoat policies" || true
220234
- name: Restore examples
221235
uses: actions/cache/restore@v4
222236
with:
@@ -226,6 +240,6 @@ jobs:
226240
- name: Commit examples
227241
run: |
228242
git add packages/examples/packages
229-
git commit -m "Update example snaps" || true
243+
git commit -m "${COMMIT_PREFIX}Update example snaps" || true
230244
- name: Push changes
231245
run: git push

0 commit comments

Comments
 (0)