🔄 synced file(s) with dealroom/core-mothership #355
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto-synced file, managed by [dealroom/core-mothership](https://github.com/dealroom/core-mothership) | |
# The changes to this file will be automatically overwritten on the next sync. Do not edit by hand! | |
name: Automerge | |
on: | |
pull_request: | |
types: [labeled, unlabeled, synchronize, reopened] | |
permissions: read-all | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
dependabot-auto-label: | |
runs-on: ubuntu-latest | |
outputs: | |
FORCE_AUTO_APPROVE: ${{ steps.dependabot-label-minor.outputs.FORCE_AUTO_APPROVE || steps.dependabot-label-patch.outputs.FORCE_AUTO_APPROVE }} | |
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
steps: | |
- name: Dependabot metadata | |
id: dependabot-metadata | |
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0 | |
- name: Add a label for a major update | |
if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' }} | |
run: | | |
gh pr edit "$PR_URL" --add-label "update-major" | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GH_TOKEN: ${{ github.token }} | |
- name: Add a label for a minor update | |
id: dependabot-label-minor | |
if: steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor' | |
run: | | |
gh pr edit "$PR_URL" --add-label "update-minor" | |
echo "FORCE_AUTO_APPROVE=1" >> "$GITHUB_OUTPUT" | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GH_TOKEN: ${{ github.token }} | |
- name: Add a label for a patch update | |
id: dependabot-label-patch | |
if: steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' | |
run: | | |
gh pr edit "$PR_URL" --add-label "update-patch" | |
echo "FORCE_AUTO_APPROVE=1" >> "$GITHUB_OUTPUT" | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GH_TOKEN: ${{ github.token }} | |
automerge: | |
runs-on: ubuntu-latest | |
needs: dependabot-auto-label | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
if: | | |
!failure() | |
&& | |
!cancelled() | |
&& | |
( | |
contains(github.event.pull_request.labels.*.name, 'dependencies') | |
|| | |
contains(github.event.pull_request.labels.*.name, 'sync') | |
) | |
&& | |
( | |
github.event.pull_request.user.login == 'dependabot[bot]' || | |
github.event.pull_request.user.login == 'dealroomba' || | |
github.event.pull_request.user.login == 'renovate[bot]' | |
) | |
steps: | |
# We will enable automerge using the "merge commit" strategy | |
# Squash is also supported, however, not all projects allow squashing | |
- name: Enable Pull Request Automerge | |
run: | | |
gh pr merge --auto \ | |
--merge \ | |
-R ${{ github.repository }} \ | |
-d \ | |
${{ github.event.pull_request.number }} | |
env: | |
# Cannot use default GITHUB_TOKEN because other workflows will be not triggered | |
# @see https://github.com/orgs/community/discussions/55906#discussioncomment-5946239 | |
GH_TOKEN: ${{ secrets.GH_TOKEN_DEALROOMBA }} | |
- name: Get PR labels | |
id: pr-labels | |
uses: joerick/pr-labels-action@0543b277721e852d821c6738d449f2f4dea03d5f # v1.0.9 | |
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0 | |
id: auto-approve | |
name: Auto approve low risk changes | |
if: | | |
contains(steps.pr-labels.outputs.labels, 'update-minor') | |
|| | |
contains(steps.pr-labels.outputs.labels, 'update-patch') | |
|| | |
contains(steps.pr-labels.outputs.labels, 'sync') | |
|| | |
contains(steps.pr-labels.outputs.labels, 'low-risk') | |
|| | |
env.FORCE_AUTO_APPROVE == '1' | |
env: | |
FORCE_AUTO_APPROVE: ${{ needs.dependabot-auto-label.outputs.FORCE_AUTO_APPROVE }} | |
with: | |
review-message: "Auto approved (low risk update)! :+1: :rocket:" |