Skip to content

Commit

Permalink
ci(dependabot): auto-rename dependabot update PRs (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschach committed Nov 9, 2023
1 parent 9a55c6a commit ca9a5ed
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ updates:
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
commit-message:
prefix: 'build'
prefix: 'deps' # packaged dependencies
prefix-development: 'build' # dev-dependencies
#include: 'scope'
rebase-strategy: 'auto'
schedule:
interval: 'daily'
- package-ecosystem: 'github-actions' # See documentation for possible values
directory: '/' # Location of package manifests
commit-message:
prefix: 'ci(actions)'
prefix: 'ci'
rebase-strategy: 'auto'
schedule:
interval: 'daily'
36 changes: 35 additions & 1 deletion .github/workflows/dependabot-approve-and-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
name: Dependabot Pull Request Approve and Merge
on: pull_request_target
on: pull_request #_target
permissions:
pull-requests: write
contents: write
jobs:
pull-request-title-change:
runs-on: ubuntu-latest
steps:
# Checkout the source code
- name: 'Checkout source code'
uses: actions/checkout@v4

- name: 'Fetch Dependabot metadata'
id: dependabot-fetch
uses: dependabot/fetch-metadata@v1

- name: 'Split title and update'
id: split-title
if: ${{ ! contains(github.event.pull_request.title, '):' ) && contains(github.event.pull_request.title, ':') && steps.dependabot-fetch.outcome == 'success' }}
env:
TITLE: ${{ github.event.pull_request.title }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{github.event.pull_request.html_url}}
run: |
echo $TITLE
title_pt2="${TITLE##*:}"
title_pt1="${TITLE%%:*}"
gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status`
packagename="${{ steps.dependabot-fetch.outputs.dependency-names }}"
#echo "packagename is $packagename"
#echo "$title_pt1"
#echo "$title_pt2"
parensOpen="("
parensClose="):"
pr_title=$title_pt1$parensOpen$packagename$parensClose$title_pt2
echo "FINAL TITLE: $pr_title"
gh pr edit "$PR_URL" --title "$pr_title"
# Auto merge Dependabot PRs for:
# - patch updates on prod dependencies
# - minor updates on dev dependencies
dependabot-auto-merge:
needs: pull-request-title-change
# Only run for Dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{ "type": "docs", "section": "Documentation", "hidden": false },
{ "type": "perf", "section": "Performance Improvements", "hidden": false },
{ "type": "test", "section": "Tests", "hidden": false },
{ "type": "deps", "section": "Dependencies", "hidden": false },
{ "type": "build", "section": "Build System", "hidden": false },
{ "type": "ci", "section": "Continuous Integration", "hidden": false }
]
Expand Down

0 comments on commit ca9a5ed

Please sign in to comment.