-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: run pretty fix only on changed files
- Loading branch information
Showing
1 changed file
with
24 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" |