From 78d903f0d790c7f5d7abf00c2230fe72ac021a43 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 10 Apr 2024 14:27:03 +0200 Subject: [PATCH] hehee --- .github/dependabot.yml | 24 ++++++++--------- .github/workflows/dependabot-auto-merge.yml | 30 +++++++++++++++------ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 396d639..3181d24 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -20,28 +20,28 @@ updates: groups: angular: patterns: - - "@angular*" + - "@angular*" update-types: - - "minor" - - "patch" + - "minor" + - "patch" eslint: patterns: - - "*eslint*" + - "*eslint*" update-types: - - "minor" - - "patch" + - "minor" + - "patch" ngrx: patterns: - - "@ngrx/*" + - "@ngrx/*" update-types: - - "minor" - - "patch" + - "minor" + - "patch" types: patterns: - - "types/*" + - "types/*" update-types: - - "minor" - - "patch" + - "minor" + - "patch" ignore: - dependency-name: "@angular*" update-types: ["version-update:semver-major"] diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 0673ed0..bad1925 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -1,19 +1,33 @@ -name: Dependabot auto-merge +name: Dependabot approve and merge + on: pull_request_target -permissions: - pull-requests: write - contents: write + jobs: dependabot: runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' + if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} steps: + ## Extract information about the dependencies being updated by a Dependabot-generated PR - name: Dependabot metadata id: dependabot-metadata - uses: dependabot/fetch-metadata@v1 + uses: dependabot/fetch-metadata@v2.0.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Checkout repository + uses: actions/checkout@v4 + + ## NOTE: This step is only required if the repository has been configured to Require approval + ## Checks if update-type is patch or minor, then approve if the PR status is not approved yet. + - name: Auto approve patch and minor updates + uses: hmarr/auto-approve-action@v4 + if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}} + + ## NOTE: Requirements for merge has to be configured in the Branch protection rule page. + ## To do so, go to repository > Settings > Branches > Edit. - name: Enable auto-merge for Dependabot PRs - if: steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' + if: ${{ contains(github.event.pull_request.title, 'bump')}} run: gh pr merge --auto --merge "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}