11name : Prettier Fix
22
3+ env :
4+ PNPM_VERSION : " 9.6.0"
5+ NODE_VERSION : " 20.16.0"
6+
7+ permissions :
8+ contents : write
9+
310on :
4- workflow_dispatch :
5- inputs :
6- reason :
7- description : " Reason for manually triggering this workflow"
8- required : false
9- schedule :
10- - cron : " 0 0 * * 0"
11+ pull_request_target :
12+ types : [labeled]
1113
1214jobs :
13- prettier-fix :
14- permissions : write-all
15+ prettify :
1516 runs-on : ubuntu-latest
17+ if : github.event.label.name == 'prettify'
1618 steps :
17- - uses : actions/checkout@v4
18- - name : Set up date environment variables
19- run : |
20- echo "BRANCH_TITLE=pretty-fix-$(date +%s)" >> $GITHUB_ENV
21- echo "PR_TITLE=Prettier Fix - $(date)" >> $GITHUB_ENV
19+ - name : Checkout code
20+ uses : actions/checkout@v4
2221
2322 - name : Set up Node.js
2423 uses : actions/setup-node@v4
2524 with :
26- node-version : " 20.16.0 "
25+ node-version : ${{ env.NODE_VERSION }}
2726
28- - name : Install dependencies
29- run :
npm i [email protected] --save-dev --save-exact 27+ - name : Setup pnpm
28+ uses : pnpm/action-setup@v4
29+ with :
30+ version : ${{ env.PNPM_VERSION }}
3031
31- - name : Pretty Check
32- run : npm run pretty-fix
32+ - name : Install prettier
33+ run :
pnpm add -g [email protected] 3334
34- - name : Create commits
35- id : commits
36- continue-on-error : true
37- run : |
38- git config user.name 'monkeytypegeorge'
39- git config user.email '[email protected] ' 40- git add .
41- git commit -m 'refactor: run prettier'
35+ - name : Run Prettier fix
36+ run : pnpm prettier --write .
37+
38+ - name : Commit changes
39+ uses : stefanzweifel/git-auto-commit-action@v5
40+ with :
41+ commit_message : " prettier fix"
4242
43- - name : Create pull request
44- uses : peter-evans/create-pull-request@v4
43+ - name : Remove label
44+ uses : actions/github-script@v7
4545 with :
46- branch : ${{ env.BRANCH_TITLE }}
47- title : ${{ env.PR_TITLE }}
48- body : ${{ env.PR_TITLE }}
46+ script : |
47+ const { context, github } = require('@actions/github');
48+ await github.rest.issues.removeLabel({
49+ owner: context.repo.owner,
50+ repo: context.repo.repo,
51+ issue_number: context.issue.number,
52+ name: 'prettify'
53+ });
0 commit comments