Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Dependabot config #9

Merged
merged 8 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "09:00"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- package-ecosystem: "npm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we only limit this to minor version upgrades?

directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "09:00"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
63 changes: 63 additions & 0 deletions .github/workflows/auto-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Merge Dependabot version bumps
on:
schedule:
# Run this task everyday at 08:00am, Monday to Friday
- cron: "0 10 * * 0"

jobs:
get-dependabot-prs:
runs-on: ubuntu-22.04
steps:
- name: Get dependabot's PRs
run: |
echo "::set-output name=basePrs::$(gh pr list --json baseRefName,headRefName,number --label 'dependencies' --author 'app/dependabot' --repo 'verto-health/astral-accessibility')"
id: list

outputs:
basePrs: ${{ steps.list.outputs.basePrs }}

auto-pr-merge:
# check list not empty
if: fromJson(needs.get-dependabot-prs)[0] != null
needs: get-dependabot-prs

runs-on: ubuntu-22.04
strategy:
matrix:
pr: ${{ fromJson(needs.get-dependabot-prs) }}
steps:
# checks out base branch
- uses: actions/checkout@v2
with:
ref: ${{ matrix.pr.baseRefName }}
fetch-depth: 0

- name: Auto approve the Pull Request
uses: hmarr/auto-approve-action@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
pull-request-number: ${{ matrix.pr.number }}

- name: Dependabot rebase
run: |
gh pr comment ${{ matrix.pr.number }} -b "@dependabot rebase"

- name: Automerge Pull Request ${{ matrix.pr.number }}
id: automerge
uses: "pascalgn/automerge-action@v0.15.0"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST: ${{ matrix.pr.number }}
MERGE_RETRY_SLEEP: 10000
MERGE_DELETE_BRANCH: true

- name: Comment error if merge failed
if: (steps.automerge.outputs.mergeResult != 'merged')
run: |
gh pr comment ${{ matrix.pr.headRefName }} -b "Merge failed, merge result was ${{ steps.automerge.outputs.mergeResult }}. PR-${{ steps.automerge.outputs.pullRequestNumber }} updated"
gh pr edit ${{ matrix.pr.headRefName }} --add-label 'Cannot update'
gh pr close ${{ steps.cpr.outputs.pull-request-number }} -c 'Failed to merge because it was ${{ steps.automerge.outputs.mergeResult }}' -d
- name: Remove 'Cannot update' tag if present
if: ${{ (steps.pr-created.outputs.is-created == 'true') && (steps.automerge.outputs.mergeResult == 'merged') }}
run: |
gh pr edit ${{ matrix.pr.headRefName }} --remove-label 'Cannot update'