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

ci(dependabot): auto-rename dependabot update PRs #33

Merged
merged 1 commit into from
Nov 9, 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
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
Loading