Skip to content

Commit

Permalink
feat: Dependabot auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk committed Sep 21, 2023
1 parent 0b0e8b5 commit bcec4be
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "wednesday"
time: "16:00"
timezone: "Europe/London"
groups:
development-dependencies:
dependency-type: "development"
exclude-patterns:
- "eslint*"
- "jasmine*"
eslint:
dependency-type: "development"
patterns:
- "eslint*"
jasmine:
dependency-type: "development"
patterns:
- "jasmine*"
25 changes: 25 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dependabot and CI auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge "$PR_URL" --auto --body "" --squash
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Auto-approve Dependabot PRs
uses: hmarr/auto-approve-action@v3

71 changes: 71 additions & 0 deletions .github/workflows/eslint-auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: ESLint Fix
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot-metadata:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
outputs:
dependency-group: ${{ steps.metadata.outputs.dependency-group }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
create-pr:
runs-on: ubuntu-latest
needs: dependabot-metadata
if: ${{needs.dependabot-metadata.outputs.dependency-group == 'eslint' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
run: npm ci
- name: Lint Fix
run: npm run lint-fix
- name: git reset to include the version bumps in the PR
run: git reset HEAD~1
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
path: ./
token: ${{ secrets.DEPENDABOT_PUBLIC_REPO_ACCESS_TOKEN }}
commit-message: ESLint --fix
committer: openactive-bot <[email protected]>
author: openactive-bot <[email protected]>
signoff: false
branch: ci/eslint
base: master
delete-branch: true
title: 'ESLint fix'
body: |
Lint fixes based on the latest version of ESLint.
labels: |
automated pr
draft: false
- name: Auto-approve PR
uses: hmarr/auto-approve-action@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge "$PR_URL" --auto --body "" --squash
env:
PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

0 comments on commit bcec4be

Please sign in to comment.