Skip to content

Commit

Permalink
ci: run pretty fix only on changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Jan 23, 2025
1 parent 90590a3 commit e4517eb
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions .github/workflows/pretty-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,36 @@ jobs:
- name: Install prettier
run: pnpm add -g [email protected]

- name: Get changed files
id: get-changed-files
uses: actions/github-script@v7
with:
script: |
const changedFiles = await github.paginate(
github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
}
);
return changedFiles.filter(file=> file.status !== "removed").map(file => file.filename).join(' ');
- name: Run Prettier fix
run: pnpm prettier --write .
run: |
CHANGED_FILES=$(echo ${{ steps.get-changed-files.outputs.result }})
if [ -n "$CHANGED_FILES" ]; then
pnpm prettier --write $CHANGED_FILES
fi
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "prettier fix"

- name: Remove label
uses: actions/github-script@v7
uses: PauMAVA/[email protected]
with:
script: |
const { context, github } = require('@actions/github');
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'prettify'
});
issue_number: ${{ github.event.pull_request.number }}
remove: "prettify"

0 comments on commit e4517eb

Please sign in to comment.