Skip to content

Commit 3fae904

Browse files
authored
Merge pull request #456 from 1Password/mrj/452/flake-ci-updates
chore(ci): Auto-add one approval to automated flake.lock PRs
2 parents 39ed88f + e98eb98 commit 3fae904

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This job applies one approval automatically to the automated `flake.lock` PRs
2+
# This helps us keep up with the weekly automated PRs, but still requires at least 1
3+
# human manual approval.
4+
name: Approve flake.lock PRs (still require 1 human approval)
5+
permissions:
6+
pull-requests: write
7+
on:
8+
pull_request_target:
9+
paths:
10+
- 'flake.lock' # only run if flake.lock has changed
11+
jobs:
12+
approve-flake-lock-prs:
13+
runs-on: ubuntu-latest
14+
if: github.actor == 'github-actions[bot]' && github.event.pull_request.labels.*.name == 'flake.lock automation'
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Approve flake.lock PRs (still requires 1 human approval)
18+
run: |
19+
# only run if only exactly 1 file is changed;
20+
# this combined with the `paths:` filter on the job itself
21+
# ensures that the PR changes ONLY flake.lock and no other files
22+
if [[ "$(git diff --name-only HEAD..origin/main | wc -l)" = 1 ]]; then
23+
gh pr review --approve "$PR_URL"
24+
end
25+
env:
26+
PR_URL: ${{github.event.pull_request.html_url}}
27+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/update-flake-dependencies.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,10 @@ jobs:
3333
--field content=@<(base64 -i $FILE_TO_COMMIT) \
3434
--field branch="$COMMIT_BRANCH" \
3535
--field sha="$(git rev-parse $COMMIT_BRANCH:$FILE_TO_COMMIT)"
36-
gh pr create --title "[automation]: Update Flake dependencies" --body "This is an automated PR to update \`flake.lock\`" --reviewer mrjones2014 --reviewer AndyTitu --base main --head $COMMIT_BRANCH
36+
gh pr create --title "[automation]: Update Flake dependencies" \
37+
--body "This is an automated PR to update \`flake.lock\`" \
38+
--label "flake.lock automation" \
39+
--reviewer mrjones2014 \
40+
--reviewer AndyTitu \
41+
--base main --head $COMMIT_BRANCH
3742
fi

0 commit comments

Comments
 (0)