Skip to content

[FIX] response 수정 #134

[FIX] response 수정

[FIX] response 수정 #134

name: CI and request Discord Message to review
on:
pull_request:
branches:
- 'develop'
types:
- opened
- reopened
- synchronize
#동시성 환경을 해결한다
concurrency:
group: ${{ github.ref }} # 동일한 PR에 대한 식별자
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
write-all
services: #mysql 설정
mysql:
image: mysql:8.0
ports:
- 3307:3306
env:
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: testdb
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis
ports:
- 6380:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: JDK 17 를 준비한다.
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: gradlew 의 root 실행권한을 부여한다.
run: chmod +x gradlew
- name: Gradle 를 준비한다.
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: ACT 환경에 대해서 패키지를 업데이터 & 설치한다
if: ${{ env.ACT }}
run: |
apt-get update && apt-get install sudo -y
- name: sudo 설치 테스트한다
if: ${{ env.ACT }}
run: |
sudo id
- name: DDL 경로 확인
run: |
ls -al infra/sql/
cat infra/sql/ddl.sql
- name: DDL 파일을 실행하여 테이블을 생성한다.
run: |
sudo apt-get install -y default-mysql-client
mysql -h 127.0.0.1 -P 3307 -uroot -ptestdb testdb --verbose < infra/sql/ddl.sql
- name: 빌드한다.
env:
SPRING_DATASOURCE_URL: jdbc:mysql://127.0.0.1:3307/testdb
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: testdb
SPRING_DATA_REDIS_HOST: 127.0.0.1
SPRING_DATA_REDIS_PORT: 6380
SPRING_DATA_REDIS_PASSWORD:
MONGO_URL: ${{ secrets.MONGO_URL }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
DEFAULT_BUCKET_URL: ${{ secrets.DEFAULT_BUCKET_URL }}
run: ./gradlew build --stacktrace
# Test 후 Report 생성
- name: 테스트 결과를 게시한다.
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: '**/build/test-results/test/TEST-*.xml'
- name: 실패시 공지한다.
if: failure()
run: |
echo failed!
send_discord_message:
needs: build
if: always()
runs-on: ubuntu-latest
steps:
- name: 상황에 맞는 메세지를 결정한다.
run: |
if [ "${{ github.event.action }}" == "opened" ]; then
echo "PR_ACTION_MESSAGE=:blush: PR 생성되었습니다" >> $GITHUB_ENV
elif [ "${{ github.event.action }}" == "reopened" ]; then
echo "PR_ACTION_MESSAGE=:blush: PR 재생성 되었습니다" >> $GITHUB_ENV
elif [ "${{ github.event.action }}" == "synchronize" ]; then
echo "PR_ACTION_MESSAGE=:blush: 기존 PR에 commit 이 추가되었습니다" >> $GITHUB_ENV
fi
- name: 작업자와 리뷰어를 결정한다.
run: |
if [ "${{ github.actor }}" == "david-parkk" ]; then
echo "DISCORD_OWNER_ID=<@568069533214965760>" >> $GITHUB_ENV
echo "DISCORD_REVIEWER_ID=<@373383545873235970>" >> $GITHUB_ENV
else
echo "DISCORD_OWNER_ID=<@373383545873235970>" >> $GITHUB_ENV
echo "DISCORD_REVIEWER_ID=<@568069533214965760>" >> $GITHUB_ENV
fi
- name: 성공시 Discord 메세지를 보낸다
if: ${{ needs.build.result == 'success' }}
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: 개발진스
DISCORD_AVATAR: "https://github.com/user-attachments/assets/1ff8e3ad-40c1-4a99-85cf-367376ed5d93"
DISCORD_EMBEDS: '
[
{
"url": "${{github.event.pull_request.html_url}}",
"title": "${{ env.PR_ACTION_MESSAGE }}",
"fields": [
{
"name": "작업자",
"value": "${{env.DISCORD_OWNER_ID}}\n\u200B\n\u200B\n",
"inline": true
},
{
"name": "리뷰어",
"value": "${{env.DISCORD_REVIEWER_ID}}\n",
"inline": true
},
{
"name": "내용",
"value": "[${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})"
}
]
}
]'
- name: 실패시 실패 메세지를 보낸다
if: ${{ needs.build.result == 'failure' }}
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: 개발진스
DISCORD_AVATAR: "https://github.com/user-attachments/assets/1ff8e3ad-40c1-4a99-85cf-367376ed5d93"
DISCORD_EMBEDS: '
[
{
"url": "${{github.event.pull_request.html_url}}",
"title": ":sob: 테스트에 실패했습니다. 다시 확인해주세요 ",
"fields": [
{
"name": "작업자",
"value": "${{env.DISCORD_OWNER_ID}}\n\u200B\n",
"inline": true
},
{
"name": "내용",
"value": "[${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})"
}
]
}
]'