Skip to content

Commit

Permalink
Modify workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisli30 committed Oct 26, 2024
1 parent 709694d commit a08c758
Showing 1 changed file with 21 additions and 32 deletions.
53 changes: 21 additions & 32 deletions .github/workflows/pr-changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
remind:
name: Changeset Reminder
changeset:
name: Run Changeset
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
Expand All @@ -15,36 +15,25 @@ jobs:
with:
fetch-depth: 0

- name: Check for Changeset
id: changeset-check
run: |
echo "Checking for changeset files..."
CHANGESET_FILES=$(git diff --name-only origin/${{ github.base_ref }}..origin/${{ github.head_ref }} | grep '^\.changeset/' || true)
echo "Changeset files found: $CHANGESET_FILES"
if [ -n "$CHANGESET_FILES" ]; then
echo "changeset=true" >> $GITHUB_OUTPUT
echo "Changeset found"
else
echo "changeset=false" >> $GITHUB_OUTPUT
echo "No changeset found"
fi
- name: Add Changeset Reminder Comment
if: steps.changeset-check.outputs.changeset == 'false'
uses: actions/github-script@v6
- name: Setup Node.js
uses: actions/setup-node@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('Adding changeset reminder comment...');
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: 'Thank you for your contribution! It seems that this PR does not include a changeset. If this PR includes changes that should be reflected in the changelog, please add a changeset by running `npm run changeset` and committing the generated file. If no changeset is needed, you can ignore this message.'
});
console.log('Changeset reminder comment added successfully');
node-version: "16"

- name: Install dependencies
run: npm ci

- name: Run Changeset
run: npm run changeset

# Optional: Examine the changes generated by Changeset
- name: Review Changeset Files
run: cat .changeset/* || echo "No changeset files created"

- name: Log Workflow Summary
- name: Commit and push changes
run: |
echo "Workflow Summary:"
echo "- PR
git config --local user.email "[email protected]" # Use operational account email
git config --local user.name "GitHub Action"
git add .changeset
git commit -m "Add changeset" || echo "No changes to commit"
git push

0 comments on commit a08c758

Please sign in to comment.