Skip to content

Commit d519137

Browse files
committed
fix: run only if ONLY flake.lock is changed
1 parent 160ee7b commit d519137

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/approve-flake-lock-prs.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@
44
name: Approve flake.lock PRs (still require 1 human approval)
55
permissions:
66
pull-requests: write
7+
on:
8+
pull_request_target:
9+
paths:
10+
- 'flake.lock' # only run if flake.lock has changed
711
jobs:
812
approve-flake-lock-prs:
913
runs-on: ubuntu-latest
1014
if: github.actor == 'github-actions[bot]' && github.event.pull_request.labels.*.name == 'flake.lock automation'
1115
steps:
1216
- name: Approve flake.lock PRs (still requires 1 human approval)
13-
run: gh pr review --approve "$PR_URL"
17+
run: |
18+
# only run if only exactly 1 file is changed;
19+
# this combined with the `paths:` filter on the job itself
20+
# ensures that the PR changes ONLY flake.lock and no other files
21+
if [[ "$(git diff --name-only HEAD..origin/main | wc -l)" = 1 ]]; then
22+
gh pr review --approve "$PR_URL"
23+
end
1424
env:
1525
PR_URL: ${{github.event.pull_request.html_url}}
1626
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)