Repository navigation
137 lines (120 loc) · 4.39 KB
/
Copy pathCI.yml
File metadata and controls
137 lines (120 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: General CI script
permissions:
checks: write
pull-requests: write
contents: write
on:
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Lint & fix using Biome (Backend)
id: lint
continue-on-error: true
run: |
set +e
OUTPUT="$(npx @biomejs/biome lint ./Backend/ --write 2>&1)"
EXIT_CODE=$?
echo 'lint_output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
- name : Create comment
if: steps.lint.outputs.exit_code != '0'
uses: mshick/add-pr-comment@v2
with:
message: |
**There is one or more linting errors (Backend)**
<details>
<summary>Lint Issues</summary>
${{ steps.lint.outputs.lint_output }}
</details>
🌏
message-id: backend
- name: Lint & fix using Biome (Frontend)
id: biomelint
continue-on-error: true
run: |
set +e
OUTPUT="$(find Frontend/src/ -type f ! -path 'Frontend/src/index.css' ! -path 'Frontend/src/utils/tests/*' | xargs npx @biomejs/biome lint --write 2>&1)"
EXIT_CODE=$?
echo 'lint_output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
- name : Create comment
if: steps.biomelint.outputs.exit_code != '0'
uses: mshick/add-pr-comment@v2
with:
message: |
**There is one or more linting errors (Frontend)**
<details>
<summary>Lint Issues</summary>
${{ steps.biomelint.outputs.lint_output }}
</details>
🌏
message-id: frontend
- name: Lint & fix using Biome (Admin Dashboard)
id: adminlint
continue-on-error: true
run: |
set +e
OUTPUT="$(find AdminDashboard/src/ -type f ! -path 'AdminDashboard/src/index.css' ! -path 'AdminDashboard/src/tests/*' | xargs npx @biomejs/biome lint --write 2>&1)"
EXIT_CODE=$?
echo 'lint_output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
- name : Create comment
if: steps.adminlint.outputs.exit_code != '0'
uses: mshick/add-pr-comment@v2
with:
message: |
**There is one or more linting errors (Admin FE)**
<details>
<summary>Lint Issues</summary>
${{ steps.adminlint.outputs.lint_output }}
</details>
🌏
message-id: admin
- name: Wait on other checks to complete
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-name: 'backend'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Push changed code if lint fails
if: steps.lint.outputs.exit_code != '0' || steps.biomelint.outputs.exit_code != '0'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Fixed some lint errors"
git push
echo "Exiting workflow due to remaining lint errors"
exit 1
- name: Format backend using prettier
run: |
npx @biomejs/biome format --indent-width=4 --indent-style=space ./Backend/ --write
- name: Format frontend using biome
run: |
npx @biomejs/biome format --indent-width=4 --indent-style=space ./Frontend/ --write
- name: Format frontend using biome
run: |
npx @biomejs/biome format --indent-width=4 --indent-style=space ./AdminDashboard/ --write
- name: Push formatted changes
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Prettified code 💅" || exit 0
git push