aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/auto-merge.yml
blob: d051de754bc54efb619db0f98e8475f7b183eff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# see https://gist.github.com/xt0rted/46475099dc0a70ba63e16e3177407872

name: Dependabot auto-merge

on:
  pull_request:
    branches:
      - master

permissions:
  contents: read
  pull-requests: read

jobs:
  auto-merge:
    runs-on: ubuntu-latest

    if: github.actor == 'dependabot[bot]'

    steps:
      - name: Create token
        id: create_token
        uses: tibdex/github-app-token@v2
        with:
          app_id: ${{ secrets.BIG_MERGER_APP_ID }}
          private_key: ${{ secrets.BIG_MERGER_PRIVATE_KEY }}

      - name: Dependabot metadata
        id: dependabot-metadata
        uses: dependabot/fetch-metadata@v1
        with:
          github-token: "${{ secrets.GITHUB_TOKEN }}"

      - name: Authenticate cli
        run: echo "${{ steps.create_token.outputs.token }}" | gh auth login --with-token

      - name: Enable auto-merge for Dependabot PRs
        if: contains(fromJSON('["version-update:semver-patch", "version-update:semver-minor"]'), steps.dependabot-metadata.outputs.update-type)
        run: gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}