Skip to content

Commit d67ad35

Browse files
authored
Update Dependabot update workflow (#3068)
`github.event` doesn't propagate to called workflows, so `github.event.issue.number` would not be set. This attempts to fix it by providing the PR number from the main workflow.
1 parent 2b03bf0 commit d67ad35

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: ./.github/workflows/update-pull-request.yml
2828
with:
2929
dependabot: true
30+
pull-request: ${{ github.event.pull_request.number }}
3031
secrets:
3132
PULL_REQUEST_UPDATE_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
3233

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ on:
1313
type: boolean
1414
required: false
1515
default: false
16+
pull-request:
17+
type: number
18+
required: false
19+
default: 0
1620

1721
jobs:
1822
is-fork-pull-request:
1923
name: Determine whether this issue comment was on a pull request from a fork
20-
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot update-pr') || inputs.dependabot == true }}
24+
if: ${{ inputs.dependabot == true || (github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot update-pr')) }}
2125
runs-on: ubuntu-latest
2226
outputs:
2327
IS_FORK: ${{ steps.is-fork.outputs.IS_FORK }}
@@ -28,7 +32,7 @@ jobs:
2832
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT"
2933
env:
3034
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
PR_NUMBER: ${{ github.event.issue.number }}
35+
PR_NUMBER: ${{ inputs.pull-request != 0 && inputs.pull-request || github.event.issue.number }}
3236

3337
react-to-comment:
3438
name: React to the comment
@@ -69,7 +73,7 @@ jobs:
6973
run: gh pr checkout "${PR_NUMBER}"
7074
env:
7175
GITHUB_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
72-
PR_NUMBER: ${{ github.event.issue.number }}
76+
PR_NUMBER: ${{ inputs.pull-request != 0 && inputs.pull-request || github.event.issue.number }}
7377
- name: Use Node.js
7478
uses: actions/setup-node@v4
7579
with:
@@ -92,7 +96,7 @@ jobs:
9296
run: gh pr checkout "${PR_NUMBER}"
9397
env:
9498
GITHUB_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
95-
PR_NUMBER: ${{ github.event.issue.number }}
99+
PR_NUMBER: ${{ inputs.pull-request != 0 && inputs.pull-request || github.event.issue.number }}
96100
- name: Setup Node.js
97101
uses: actions/setup-node@v4
98102
with:
@@ -121,7 +125,7 @@ jobs:
121125
run: gh pr checkout "${PR_NUMBER}"
122126
env:
123127
GITHUB_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
124-
PR_NUMBER: ${{ github.event.issue.number }}
128+
PR_NUMBER: ${{ inputs.pull-request != 0 && inputs.pull-request || github.event.issue.number }}
125129
- name: Restore yarn.lock
126130
uses: actions/cache/restore@v4
127131
with:
@@ -156,7 +160,7 @@ jobs:
156160
run: gh pr checkout "${PR_NUMBER}"
157161
env:
158162
GITHUB_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
159-
PR_NUMBER: ${{ github.event.issue.number }}
163+
PR_NUMBER: ${{ inputs.pull-request != 0 && inputs.pull-request || github.event.issue.number }}
160164
- name: Restore yarn.lock
161165
uses: actions/cache/restore@v4
162166
with:
@@ -200,7 +204,7 @@ jobs:
200204
run: gh pr checkout "${PR_NUMBER}"
201205
env:
202206
GITHUB_TOKEN: ${{ secrets.PULL_REQUEST_UPDATE_TOKEN }}
203-
PR_NUMBER: ${{ github.event.issue.number }}
207+
PR_NUMBER: ${{ inputs.pull-request != 0 && inputs.pull-request || github.event.issue.number }}
204208
- name: Configure Git
205209
run: |
206210
git config --global user.name 'MetaMask Bot'

0 commit comments

Comments
 (0)