Skip to content

Update README.md

Update README.md #67

Workflow file for this run

name: CI/CD
# Action Trigger
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# JAVA 17 설정(corretto 배포)
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'
# Gradlew 실행 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Gradlew 빌드 실행(test 생략)
- name: Build with Gradle
run: ./gradlew build -x test
# 다중 아키텍쳐 배포를 위한 설정
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Buildx를 사용 설정
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Docker 로그인
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
# DockerHub에 push
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: geumyeon/calendar:latest
platforms: linux/amd64,linux/arm64
# AWS 로그인
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
# AWS 세션 매니저 접속
- name: Start Session Manager session
run: aws ssm start-session --target i-0d06e891326522e28
# 배포
- name: Deploy to Server
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ap-northeast-2
run: |
aws ssm send-command \
--instance-ids i-0d06e891326522e28 \
--document-name "AWS-RunShellScript" \
--parameters "commands=[
'if sudo docker ps -a --format \\'{{.Names}}\\' | grep -q \'^calendar$\\'; then',
' sudo docker stop calendar',
' sudo docker rm calendar',
'fi',
'if sudo docker ps -a --format \\'{{.Names}}\\' | grep -q \'^redis$\\'; then',
' sudo docker stop redis',
' sudo docker rm redis',
'fi',
'sudo docker rmi geumyeon/calendar:latest',
'sudo docker rmi calendar:latest',
'sudo docker pull geumyeon/calendar:latest',
'sudo docker tag geumyeon/calendar:latest calendar',
'sudo docker compose up -d'
]" \
--output text