Skip to content

Commit

Permalink
Merge pull request #778 from SciCatProject/SWAP-3518-scicat-be-automa…
Browse files Browse the repository at this point in the history
…te-merge-for-dependabot-pr

chore: auto-merge dependabot patch versions
  • Loading branch information
nitrosx authored Oct 2, 2023
2 parents df18c8a + 38aa0ba commit 0a82027
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/auto-merge-dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Dependabot auto-merge

on: pull_request_target

permissions:
pull-requests: write
contents: write
packages: read

jobs:
dependabot:
runs-on: ubuntu-latest
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/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

## 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.
## Token with PR approval permission is required
- name: Approve patch and minor updates
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}}
run: |
gh pr checkout "$PR_URL"
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
then
gh pr review --approve "$PR_URL"
else
echo "PR already approved.";
fi
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.PR_APPROVE_TOKEN}}

## 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: ${{ contains(github.event.pull_request.title, 'bump')}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}


- name: Restore node_modules
id: cached-node-modules
uses: actions/cache@v3
Expand Down

0 comments on commit 0a82027

Please sign in to comment.