Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Auto-add one approval to automated flake.lock PRs #456

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/approve-flake-lock-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This job applies one approval automatically to the automated `flake.lock` PRs
# This helps us keep up with the weekly automated PRs, but still requires at least 1
# human manual approval.
name: Approve flake.lock PRs (still require 1 human approval)
permissions:
pull-requests: write
on:
pull_request_target:
paths:
- 'flake.lock' # only run if flake.lock has changed
jobs:
approve-flake-lock-prs:
runs-on: ubuntu-latest
if: github.actor == 'github-actions[bot]' && github.event.pull_request.labels.*.name == 'flake.lock automation'
mrjones2014 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v4
- name: Approve flake.lock PRs (still requires 1 human approval)
run: |
# only run if only exactly 1 file is changed;
# this combined with the `paths:` filter on the job itself
# ensures that the PR changes ONLY flake.lock and no other files
if [[ "$(git diff --name-only HEAD..origin/main | wc -l)" = 1 ]]; then
gh pr review --approve "$PR_URL"
end
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
7 changes: 6 additions & 1 deletion .github/workflows/update-flake-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ jobs:
--field content=@<(base64 -i $FILE_TO_COMMIT) \
--field branch="$COMMIT_BRANCH" \
--field sha="$(git rev-parse $COMMIT_BRANCH:$FILE_TO_COMMIT)"
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
gh pr create --title "[automation]: Update Flake dependencies" \
--body "This is an automated PR to update \`flake.lock\`" \
--label "flake.lock automation" \
--reviewer mrjones2014 \
--reviewer AndyTitu \
--base main --head $COMMIT_BRANCH
fi
Loading