Skip to content

Commit

Permalink
Merge pull request #2 from rmartin16/ci-workflows
Browse files Browse the repository at this point in the history
Consolidate Dependabot Change Note Workflow
  • Loading branch information
freakboy3742 authored Dec 11, 2022
2 parents 6535d85 + 5a82d05 commit 440e711
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/dependabot-changenote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Dependabot Change Note

on:
workflow_call:

permissions:
pull-requests: write

jobs:
changenote:
name: Dependabot Change Note
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
token: ${{ secrets.BRUTUS_PAT_TOKEN }}

- name: Configure git
run: |
git config --local user.email "$(git log --pretty='%ae' -1)"
git config --local user.name "Dependabot[bot]"
- name: Commit Change Note
run: |
# Fetch PR number for commit from Github API
API_URL="${{ github.api_url }}/repos/${{ github.repository }}/commits/${{ github.event.head_commit.id }}/pulls"
PR_NUM=$(curl -s -H "Accept: application/vnd.github+json" "${API_URL}" | jq -r '.[].number')
# Create change note from first line of dependabot commit
NEWS=$(printf "%s" "${{ github.event.head_commit.message }}" | head -n1 | sed -e 's/Bump/Updated/')
printf "%s.\n" "${NEWS}" > "./changes/${PR_NUM}.misc.rst"
# Commit the change note
git add "./changes/${PR_NUM}.misc.rst"
# "dependabot skip" tells Dependabot to continue rebasing this branch despite foreign commits
git commit -m "Add changenote. [dependabot skip]"
- name: Push
run: git push origin

0 comments on commit 440e711

Please sign in to comment.