Skip to content

Commit

Permalink
CI 스크립트 개선 (issue #108) (#111)
Browse files Browse the repository at this point in the history
* refactor: 백엔드, 프론트엔드 ci 파일 분리 및 gradle 캐싱

* refactor: 백엔드, 프론트엔드 ci 파일 분리 및 gradle 캐싱

* refactor: 성능 측정을 위한 gradle 캐싱 주석 처리

* refactor: 성능 측정을 위한 gradle 캐싱 주석 해제

* refactor: 성능 측정을 위한 백엔드 패키지 수정

* refactor: ci path 수정

* refactor: 성능 측정을 위한 백엔드 패키지 수정

* refactor: 테스트를 위한 주석 원복

* refactor: gradle run 변경 및 불필요한 부분 제거

* refactor: teamMember env 설정 테스트

* refactor: ci 트리거를 위한 주석

* fix: gradle uses 수정

* fix: pull request assignee 가져오는 부분 변경

* fix: pr assignees 할당 변경

* fix: pr assignee 할당 수정

* fix: env 추가

* refactor: pr assignee 를 sender 로 변경

* refactor: sender 를 assignee 로 변경 테스트

* refactor: sender 로 변경

* refactor: 불필요한 주석 삭제

* refactor: 불필요한 주석 제거
  • Loading branch information
lilychoibb committed Jul 24, 2024
1 parent d1c3114 commit 4df524c
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 88 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: BACKEND_CI

on:
pull_request:
types: [ opened, reopened, synchronize ]
branches: [ 'main' ]
paths:
- backend/**

env:
lilychoibb: "U07AQJWU8S3"
robinjoon: "U07BU02FQFJ"
brgndyy: "U07B53DM02W"
chosim-dvlpr: "U07BHP5UTLH"
Minjoo522: "U07B4V80WLT"
alstn113: "U07AQK2KBLP"
le2sky: "U07B26581CM"
Parkhanyoung: "U07BTSGKCC8"

jobs:
BE_CI:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Test with Gradle
continue-on-error: true
id: gradle_test
run: |
cd backend
./gradlew test
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
id: teamMember
run: |
echo "SENDER_SLACK_ID=${{ env[github.event.sender.login] }}" >> $GITHUB_ENV
- 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 담당자: <@${{ env.SENDER_SLACK_ID }}>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
82 changes: 4 additions & 78 deletions .github/workflows/ci.yml → .github/workflows/front_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,91 +5,17 @@
# 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
name: FRONT_CI

on:
workflow_dispatch:
pull_request:
types: [ opened, reopened, synchronize ]
branches: [ 'main' ]
paths:
- frontend/**

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
Expand Down Expand Up @@ -159,7 +85,7 @@ jobs:
FE_SLACK_MESSAGE:
runs-on: ubuntu-latest
needs: [FE_CI]
needs: FE_CI
if: ${{needs.FE_CI.result != 'skipped'}}
steps:
- name: Checkout repository
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/teamMember.json

This file was deleted.

0 comments on commit 4df524c

Please sign in to comment.