File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Auto-Format with Stylelint on PR for "self-healing" PRs
2
+
3
+ on :
4
+ workflow_call :
5
+
6
+ jobs :
7
+ format :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - name : Checkout code
11
+ uses : actions/checkout@v4
12
+ with :
13
+ ref : ${{github.event.pull_request.head.ref}}
14
+ fetch-depth : 0
15
+
16
+ - name : Set up Node.js
17
+ uses : actions/setup-node@v4
18
+ with :
19
+ node-version-file : " .nvmrc"
20
+
21
+ - name : Install dependencies
22
+ run : |
23
+ npm ci
24
+
25
+ - name : Check if Stylelint update PR
26
+ id : check_pr
27
+ run : |
28
+ echo "PR title: ${{ github.event.pull_request.title }}"
29
+ if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]]; then
30
+ echo "Stylelint update detected."
31
+ echo "stylelint_update=true" >> $GITHUB_ENV
32
+ else
33
+ echo "No Stylelint update detected."
34
+ echo "stylelint_update=false" >> $GITHUB_ENV
35
+ fi
36
+
37
+ - name : Run Stylelint to format the code
38
+ if : env.stylelint_update == 'true'
39
+ run : |
40
+ npx --no stylelint "**/*.*css" --fix
41
+
42
+ - name : Commit changes if formatting is done
43
+ if : env.stylelint_update == 'true'
44
+ run : |
45
+ git config --global user.name 'github-actions[bot]'
46
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
47
+
48
+ git add .
49
+ git commit --all -m "Auto-format codebase with Stylelint" || echo "No changes to commit"
50
+ git push origin HEAD:${{ github.head_ref }} # Push back to the same PR branch
Original file line number Diff line number Diff line change 19
19
auto-merge :
20
20
uses : ./.github/workflows/99-auto-merge.yml
21
21
22
+ dependabot-stylelint-self-healing :
23
+ uses : ./.github/workflows/99-auto-fix-dependabot-stylelint-updates.yml
24
+
22
25
codeql :
23
26
uses : ./.github/workflows/99-codeql-analysis.yml
24
27
You can’t perform that action at this time.
0 commit comments