Skip to content

feat: 멤버 즉시 삭제 기능 구현 (#109) #53

feat: 멤버 즉시 삭제 기능 구현 (#109)

feat: 멤버 즉시 삭제 기능 구현 (#109) #53

name: develop push Build and deploy
on:
push:
branches: [ "develop" ]
env:
DOCKERHUB_USERNAME: ject4tserver
DOCKERHUB_IMAGE_NAME: studytrip-server
jobs:
build-deploy:
runs-on: ubuntu-latest
environment: DEV
strategy:
matrix:
java-version: [ 17 ]
distribution: [ 'temurin' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.distribution }}
- name: Grant Execute Permission for Gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
id: gradle
uses: gradle/gradle-build-action@v2
with:
arguments: |
bootJar
--scan
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v5.5.0
env:
DOCKERHUB_IMAGE_FULL_NAME: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}
with:
images: ${{ env.DOCKERHUB_IMAGE_FULL_NAME }}
tags: |
type=sha,prefix=
- name: Build and Push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
- name: Deploy to EC2 Server
uses: appleboy/ssh-action@v1.0.3
env:
DOCKERHUB_IMAGE_FULL_PATH: ${{ steps.metadata.outputs.tags }}
DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: DOCKERHUB_IMAGE_FULL_PATH, DOCKERHUB_IMAGE_NAME
debug: true
script: |
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
docker compose up -d
docker image prune -a -f
# 슬랙으로 알림 전송
- name: Send to slack notification
uses: slackapi/slack-github-action@v2.1.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "Build and Deploy result"
blocks:
- type: section
text:
type: mrkdwn
text: "*✅ 배포 완료 알림*"
- type: section
text:
type: mrkdwn
text: "*실행 로그:* 🔗 <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>"
- type: context
elements:
- type: mrkdwn
text: "*브랜치:* `${{ github.ref_name }}`"
- type: mrkdwn
text: "*커밋:* `${{ github.sha }}`"
- type: divider