-
Notifications
You must be signed in to change notification settings - Fork 5
202 lines (178 loc) · 6.33 KB
/
ci.yml
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
name: CI
on:
workflow_dispatch:
pull_request:
types: [ opened, reopened, synchronize ]
branches: [ 'main' ]
jobs:
BE_CI:
if: ${{ contains(github.event.pull_request.labels.*.name, '🚛 백엔드') }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
actions: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup Gradle
run: chmod +x ./backend/gradlew
- name: Build with Gradle
continue-on-error: true
id: gradle_build
run: |
cd backend
./gradlew build
BE_SLACK_MESSAGE:
runs-on: ubuntu-latest
needs: BE_CI
if: ${{needs.BE_CI.result != 'skipped'}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Get teamMember List
id: teamMembers
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const workers = JSON.parse(fs.readFileSync('.github/workflows/teamMember.json'));
const mention = context.payload.pull_request.assignees.map((user) => {
const login = user.login;
const mappedValue = workers[login];
return mappedValue ? `<@${mappedValue}>` : `No mapping found for ${login}`;
})
return mention.join(', ');
- name: Slack mention
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.ISSUE_CHANNEL }}
payload: |
{
"text": "pr 테스트 결과",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "pr 테스트 ${{ needs.BE_CI.result }} \n • 링크: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> \n • pr 담당자: \${{ steps.teamMembers.outputs.result }}
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
FE_CI:
if: ${{ contains(github.event.pull_request.labels.*.name, '🎨 프론트엔드') }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
actions: write
outputs:
lint: ${{ steps.npm_run_lint_result.outputs.result }}
build: ${{ steps.npm_run_build_result.outputs.result }}
test: ${{ steps.npm_run_test_result.outputs.result }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.15.1'
- name: Install dependencies
run: |
cd frontend
npm install
- name: Run lint
continue-on-error: true
id: npm_run_lint
run: |
cd frontend
npm run lint
- name: Save Run lint result
continue-on-error: true
id: npm_run_lint_result
run: |
echo "result=${{steps.npm_run_lint.outcome}}" >> $GITHUB_OUTPUT
- name: Run build
continue-on-error: true
id: npm_run_build
run: |
pwd
cd frontend
npm run build
- name: Save Run build result
continue-on-error: true
id: npm_run_build_result
run: |
echo "result=${{steps.npm_run_build.outcome}}" >> $GITHUB_OUTPUT
- name: Run test
continue-on-error: true
id: npm_run_test
run: |
cd frontend
npm run test
- name: Save Run test result
continue-on-error: true
id: npm_run_test_result
run: |
echo "result=${{steps.npm_run_test.outcome}}" >> $GITHUB_OUTPUT
FE_SLACK_MESSAGE:
runs-on: ubuntu-latest
needs: [FE_CI]
if: ${{needs.FE_CI.result != 'skipped'}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Get teamMember List
id: teamMembers
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const workers = JSON.parse(fs.readFileSync('.github/workflows/teamMember.json'));
const mention = context.payload.pull_request.assignees.map((user) => {
const login = user.login;
const mappedValue = workers[login];
return mappedValue ? `<@${mappedValue}>` : `No mapping found for ${login}`;
})
return mention.join(', ');
- name: Slack mention
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.ISSUE_CHANNEL }}
payload: |
{
"text": "pr 테스트 결과",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "pr 테스트 결과\n lint : ${{ needs.FE_CI.outputs.lint }} \n build : ${{ needs.FE_CI.outputs.build }} \n test : ${{ needs.FE_CI.outputs.test }} \n • 링크: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> \n • pr 담당자: \${{ steps.teamMembers.outputs.result }}
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }}