Skip to content

Commit

Permalink
ci: update dependabot workflow (#2131)
Browse files Browse the repository at this point in the history
Co-authored-by: Sérgio Torres <30977845+Torres-ssf@users.noreply.github.com>
Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Daniel Bate <djbate23@gmail.com>
  • Loading branch information
5 people authored May 6, 2024
1 parent 31f60b7 commit 586e1e2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .changeset/gold-hornets-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

ci: update dependabot workflow
26 changes: 0 additions & 26 deletions .github/workflows/dependabot-changeset.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,38 @@ jobs:
comment_tag: diff
mode: recreate
create_if_not_exists: true
create-changeset:
needs: [test]
name: Create Changeset
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.ref }}

- name: Setup PNPM
uses: pnpm/action-setup@v2.1.0
with:
version: 9.0.5
run_install: true

- name: Install jq
run: sudo apt-get install -y jq

- name: Run dependabot changeset script
run: pnpm changeset:dependabot
env:
PR_TITLE: ${{ github.event.pull_request.title }}

- name: Commit Changeset
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add .
git commit -m "build: update dependency changeset [skip ci]"
git push origin HEAD:${{ github.event.pull_request.head.ref }}
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
9 changes: 4 additions & 5 deletions scripts/changeset/dependabot-changeset.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ latest_commit=$(git rev-parse HEAD)
# Get the list of changed package directories
changed_packages=$(git diff-tree --no-commit-id --name-only -r "$latest_commit" | grep "packages/" | sed -E 's|packages/([^/]+)/.*|\1|')

# Get the pull request title
pr_title=$(git log -1 --pretty=%B "$latest_commit" | head -n 1)

# Create the changeset content
changeset_content="---\n"
for package in $changed_packages; do
Expand All @@ -18,13 +15,15 @@ done
changeset_content+="---\n\n"

# Append the pull request title to the changeset content
changeset_content+="$pr_title"
echo "PR_TITLE: $PR_TITLE"
changeset_content+="$PR_TITLE"

# Create a new changeset file using pnpm
pnpm changeset add --empty

# Find the newly created changeset file
changeset_file=$(git status --porcelain | awk '/^?? .changeset\// {print $2}')
changeset_file=$(git status --porcelain .changeset/*.md | sed -E 's/.*(\.changeset\/.*\.md)/\1/')
echo "$changeset_file"

# Write the changeset content to the file
echo -e "$changeset_content" > "$changeset_file"

0 comments on commit 586e1e2

Please sign in to comment.