Feat(#14): Redis TTL 추가 #8
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
# Workflow title | |
name: CI/CD | |
# 이벤트 | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
# Docker image build | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# application.yml 파일 생성 | |
- name: make application.yml | |
run: | |
echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml | |
# gradlew 실행 권한 부여 | |
- run: chmod +x ./gradlew | |
# 빌드 | |
- name: Build with Gradle | |
run: ./gradlew clean build -x test | |
# Docker Login, image build, push | |
- name : Docker Login, image build, push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }} --platform linux/amd64 . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }} | |
deploy: | |
name: Deploy Docker Image to EC2 | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: SSH into EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
sudo docker-compose -f ${{ secrets.DOCKER_COMPOSE_YML_PATH }} down ${{ secrets.PROJECT_IMAGE_NAME }} | |
sudo docker-compose -f ${{ secrets.DOCKER_COMPOSE_YML_PATH }} pull ${{ secrets.PROJECT_IMAGE_NAME }} | |
sudo docker-compose -f ${{ secrets.DOCKER_COMPOSE_YML_PATH }} up -d ${{ secrets.PROJECT_IMAGE_NAME }} |