Skip to content

Commit

Permalink
Merge pull request #223 from chizmw/add-dependabot-changeset-action
Browse files Browse the repository at this point in the history
Add dependabot changeset action
  • Loading branch information
chizmw authored Aug 27, 2023
2 parents 07a9375 + 29935c5 commit 4df98fe
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-brooms-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'arcane-scripts': patch
---

chore: add dependabot changeset action workflow
70 changes: 70 additions & 0 deletions .github/workflows/dependabot-changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: Dependabot

# yamllint disable-line rule:truthy
on:
pull_request_target:

permissions:
contents: write
pull-requests: write

jobs:
add-changeset-fragment:
name: Add changeset fragment
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}

steps:
# Find the PR associated with this push, if there is one.
- uses: jwalton/gh-find-current-pr@v1
id: find-pr
with:
# Can be "open", "closed", or "all". Defaults to "open".
state: open
# This will echo "Your PR is 7", or be skipped if there is no current PR.
- run: echo "Your PR is ${PR}"
if: success() && steps.find-pr.outputs.number
env:
PR: ${{ steps.find-pr.outputs.pr }}

- uses: boonya/gh-action-name-generator@v1
if: success() && steps.find-pr.outputs.number
id: generator
with:
style: lowerCase
separator: '-'
length: 3
- run: |
echo "Generated name is: ${{ steps.generator.outputs.name }}"
- uses: actions/checkout@v3
if: success() && steps.find-pr.outputs.number
with:
# https://github.com/marketplace/actions/add-commit#working-with-prs
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Git User
if: success() && steps.find-pr.outputs.number
uses: fregante/setup-git-user@v2

- name: Render template
id: render
uses: chuhlomin/[email protected]
if: success() && steps.find-pr.outputs.number
with:
template: .github/dependabot-changeset.template.md
vars: |
prTitle: '${{ steps.find-pr.outputs.title }}'
- name: Create Changeset Fragment
if: success() && steps.find-pr.outputs.number
shell: bash
# yamllint disable rule:line-length
run: |
echo "${{ steps.render.outputs.result }}" > .changeset/${{ steps.generator.outputs.name }}.md
cat .changeset/${{ steps.generator.outputs.name }}.md
git add .changeset/${{ steps.generator.outputs.name }}.md
git commit -m "docs(changeset): add changeset fragment for ${{ steps.find-pr.outputs.title }}"
git push origin HEAD
# yamllint enable rule:line-length

0 comments on commit 4df98fe

Please sign in to comment.