fix: 프로필 조회 임원진 예외처리 제거 & 임원진 기수 팀 업데이트 시, 해당 기수 업데이트 무시하도록 처리 #607
This file contains hidden or 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: Deploy to Test Instance | |
on: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
repository_dispatch: | |
types: [deploy-to-test-event] | |
push: | |
branches: [ develop ] | |
env: | |
SPRING_PROFILES_ACTIVE: dev | |
ECR_APP_NAME: ${{ secrets.ECR_APP_NAME }}-dev | |
ECR_REPO: ${{ secrets.ECR_HOST }}/${{ secrets.ECR_APP_NAME }}-dev | |
ECR_HOST: ${{ secrets.ECR_HOST }} | |
jobs: | |
build: | |
name: CD Pipeline | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 1.17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: 'Check Java Version' | |
run: | | |
java --version | |
echo 'ecr repo is $ECR_REPO' | |
- name: 'Configure AWS credentials' | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID__TEAM_PLAYGROUND }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY__TEAM_PLAYGROUND }} | |
aws-region: ap-northeast-2 | |
- name: 'Get application.yml from AWS S3' | |
run: | | |
aws s3 cp \ | |
--region ap-northeast-2 \ | |
s3://sopt-makers-internal/dev/deploy/application-dev.yml src/main/resources/application.yml | |
- name: 'Get key from AWS S3' | |
run: | | |
aws s3 cp \ | |
--region ap-northeast-2 \ | |
s3://sopt-makers-internal/dev/deploy/${{ secrets.APPLE_KEY }} src/main/resources/static/${{ secrets.APPLE_KEY }} | |
- name: 'Build with Gradle' | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
shell: bash | |
- name: 'Login to ECR' | |
run: | | |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_HOST | |
- name: 'Docker Image Build & Push' | |
run: | | |
docker build -t $ECR_APP_NAME . | |
docker tag $ECR_APP_NAME:latest $ECR_REPO | |
docker push $ECR_REPO | |
- name: 'ECR Public: keep only latest 3 images' | |
run: | | |
set -euo pipefail | |
# 최신 순 정렬 후 3개 건너뛰고 나머지 digest 추출 | |
DIGESTS_JSON=$( | |
aws ecr-public describe-images \ | |
--region us-east-1 \ | |
--repository-name sopt-makers/playground-dev \ | |
--query 'reverse(sort_by(imageDetails, &imagePushedAt))[3:].imageDigest' \ | |
--output json | |
) | |
if [[ "$DIGESTS_JSON" == "null" || "$DIGESTS_JSON" == "[]" ]]; then | |
echo "No old images to delete (<= 3 images present)." | |
exit 0 | |
fi | |
IMAGE_IDS=$(echo "$DIGESTS_JSON" | jq '[.[] | {imageDigest: .}]') | |
aws ecr-public batch-delete-image \ | |
--region us-east-1 \ | |
--repository-name sopt-makers/playground-dev \ | |
--image-ids "$IMAGE_IDS" | |
echo "Old images deleted." | |
- name: 'Send docker-compose.yml to EC2 Instance' | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.DEV_RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }} | |
source: "./docker-compose.yml" | |
target: "/home/ec2-user/playground/" | |
- name: 'Send deploy script to EC2 Instance' | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.DEV_RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }} | |
source: "./scripts/" | |
target: "/home/ec2-user/playground/" | |
- name: 'Get current time' | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" | |
- name: 'Docker Container Run' | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DEV_RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }} | |
script: | | |
cd ~ | |
sudo docker pull $ECR_REPO | |
sudo chmod +x ./playground/scripts/*.sh | |
./playground/scripts/deploy.sh | |
docker image prune -f |