Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 배포파일 및 테스트코드 name 분리, 테스트코드 결과 제공, 배포 성공여부 슬랙메세지 전송 #228

Merged
merged 12 commits into from
Nov 13, 2024
Merged
20 changes: 17 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: 📥 Checkout Repository
uses: actions/checkout@v4

- name: Set up SSH
- name: 🔐 Set Up SSH Authentication
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Run deployment script on server
- name: 🚀 Run Deployment Script on Server
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.SERVER_IP }} "SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL }} bash /home/ubuntu/deploy.sh"
# 서버의 deploy.sh 스크립트를 통해 무중단 배포를 진행합니다.
# 무중단 배포 성공 시 Slack 알림을 전송하도록 설정되어 있습니다.

- name: 📢 Notify Deployment Status on Slack
if: always()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
if [ $? -eq 0 ]; then
curl -X POST -H 'Content-type: application/json' --data '{"text": "🎉 *최종 배포 성공* - 배포가 성공적으로 완료되었습니다!"}' $SLACK_WEBHOOK_URL
else
curl -X POST -H 'Content-type: application/json' --data '{"text": "⚠️ *배포 실패* - 배포 과정에서 문제가 발생했습니다."}' $SLACK_WEBHOOK_URL
fi
# 배포 스크립트가 성공적으로 실행되었는지 여부를 Slack으로 알립니다.
23 changes: 19 additions & 4 deletions .github/workflows/testcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- Weekly
permissions: write-all

jobs:
test:
Expand All @@ -19,6 +20,7 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5

mysql:
image: mysql:8.0
ports:
Expand All @@ -35,16 +37,16 @@ jobs:
--health-retries 5

steps:
- name: Checkout code
- name: 📥 Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Run Tests
- name: 🧪 Run Tests and Generate Results
env:
SPRING_DATASOURCE_URL: ${{ secrets.MYSQL_URL }}
SPRING_DATASOURCE_USERNAME: ${{ secrets.MYSQL_USERNAME }}
Expand All @@ -54,4 +56,17 @@ jobs:
SLACK_NOTICE_WEBHOOK_URL: ${{ secrets.SLACK_NOTICE_WEBHOOK_URL }}
SLACK_CHARGE_REQUEST_URL: ${{ secrets.SLACK_CHARGE_REQUEST_URL }}
SLACK_WITHDRAW_REQUEST_URL: ${{ secrets.SLACK_WITHDRAW_REQUEST_URL }}
run: ./gradlew test
run: ./gradlew clean build -Dspring.profiles.active=test

- name: 📑 Publish Test Results as PR Comment
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: '**/build/test-results/test/TEST-*.xml'

- name: ✅ Add Check Comments for Failed Code Lines
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
token: ${{ github.token }}
Loading