Skip to content

Commit

Permalink
Merge pull request #44 from guardian/ac/automate-prs
Browse files Browse the repository at this point in the history
Automate approval and merging of Scala Steward PRs
  • Loading branch information
aracho1 authored Jul 9, 2024
2 parents 2a70f05 + a5817f1 commit 5acd8a2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@ on:
- main

jobs:
scala_steward:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
if: github.actor == 'gu-scala-steward-public-repos[bot]'
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Check if PR has 'minor' or 'patch' label
id: check_labels
run: |
PR_URL="${{ github.event.pull_request.html_url }}"
PR_NUMBER=$(echo $PR_URL | awk -F/ '{print $NF}')
LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name')
if [[ "$LABELS" != *"minor"* && "$LABELS" != *"patch"* ]]; then
echo "PR does not have 'minor' or 'patch' label. Skipping approval and merge."
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Approve a PR
if: steps.check_labels.outputs.result == 'success'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build:
runs-on: ubuntu-latest
permissions:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/scala-steward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Original template https://github.com/scala-steward-org/scala-steward/blob/main/docs/repo-specific-configuration.md

# pullRequests.frequency allows to control how often or when Scala Steward
# is allowed to create pull requests.
pullRequests.frequency = "7 days"

# pullRequests.grouping allows you to specify how Scala Steward should group
# your updates in order to reduce the number of pull-requests.
#
# Updates will be placed in the first group with which they match, starting
# from the first in the array. Those that do not match any group will follow
# the default procedure (one PR per update).

pullRequests.grouping = [
{ name = "major", "title" = "Major updates", "filter" = [{"version" = "major"}, "customLabels" = ["major"] },
{ name = "minor", "title" = "Minor updates", "filter" = [{"version" = "minor"}, "customLabels" = ["minor"] },
{ name = "patch", "title" = "Patch updates", "filter" = [{"version" = "patch"}, "customLabels" = ["patch"] },
{ name = "all", "title" = "Other dependency updates", "filter" = [{"group" = "*"}] }
]

# pullRequests.customLabels allows to add custom labels to PRs.
# This is useful if you want to use the labels for automation (project board for example).
# Defaults to no labels (no labels are added).
pullRequests.customLabels = [ "dependencies" ]

0 comments on commit 5acd8a2

Please sign in to comment.