[Feat] 내 이름 수정 기능 추가 #32
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | |
with: | |
arguments: clean bootJar | |
- name: Create application.yml from template | |
run: | | |
cp src/main/resources/application.yml.template src/main/resources/application.yml | |
envsubst < src/main/resources/application.yml.template > src/main/resources/application.yml | |
env: | |
DB_URL: ${{ secrets.DB_URL }} | |
DB_USERNAME: ${{ secrets.DB_USERNAME }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }} | |
REDIS_HOST: ${{ secrets.REDIS_HOST }} | |
REDIS_PORT: ${{ secrets.REDIS_PORT }} | |
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }} | |
KAKAO_CLIENT_SECRET: ${{ secrets.KAKAO_CLIENT_SECRET }} | |
# AWS ECR 로그아웃 | |
- name: Logout from ECR (if logged in) | |
run: docker logout ${{ secrets.AWS_ECR_URL }} || true | |
# AWS ECR 로그인 | |
- name: Login to AWS ECR | |
run: | | |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_URL }} | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
# Docker 빌드 | |
- name: Build Docker image | |
run: docker build --no-cache -t myapp:latest . | |
# 이미지 태그 및 푸시 | |
- name: Tag and Push Docker image to ECR | |
run: | | |
docker tag myapp:latest ${{ secrets.AWS_ECR_URL }}/map-for-all:latest | |
docker push ${{ secrets.AWS_ECR_URL }}/map-for-all:latest | |
# AWS 서버에 Docker 이미지 배포 및 컨테이너 실행 | |
- name: Deploy to AWS EC2 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.AWS_HOST }} | |
username: ${{ secrets.AWS_SSH_USER }} | |
key: ${{ secrets.AWS_SSH_KEY }} | |
script: | | |
docker stop myapp || true | |
docker rm myapp || true | |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_URL }} | |
docker pull ${{ secrets.AWS_ECR_URL }}/map-for-all:latest | |
docker run -d -p 8080:3000 --name myapp ${{ secrets.AWS_ECR_URL }}/map-for-all:latest | |
docker image prune -f | |