Skip to content

refactor: traffic 환경 aop logging on #51

refactor: traffic 환경 aop logging on

refactor: traffic 환경 aop logging on #51

Workflow file for this run

name: Traffic CI/CD - Build, Push and Deploy
on:
push:
branches:
- traffic
workflow_dispatch:
inputs:
target_ref:
description: "Branch/tag/commit SHA to deploy"
required: true
default: "traffic"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: sopt-makers/crew-dev
IMAGE_TAG: traffic-latest
SPRING_PROFILES_ACTIVE: traffic
jobs:
build-push-and-deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
environment: traffic
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.target_ref || github.sha }}
- name: Inject application-secret.properties from Secrets
run: |
echo "${{ secrets.APPLICATION_SECRET_SPRING }}" > ./main/src/main/resources/application-secret.properties
shell: bash
- name: Configure AWS credentials for GitHub Actions
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: ./main
file: ./main/Dockerfile
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
SPRING_PROFILES_ACTIVE=${{ env.SPRING_PROFILES_ACTIVE }}
- name: Deploy to Traffic Server
uses: appleboy/ssh-action@v1.2.2
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ env.AWS_REGION }}
with:
host: ${{ secrets.TRAFFIC_SERVER_IP }}
username: ${{ secrets.TRAFFIC_SERVER_USER }}
key: ${{ secrets.TRAFFIC_SERVER_KEY }}
envs: AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION
script: |
sudo -E aws ecr get-login-password --region ${{ env.AWS_REGION }} | sudo docker login --username AWS --password-stdin ${{ steps.login-ecr.outputs.registry }}
export IMAGE_NAME="${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
cd ~
chmod +x ./deploy.sh
./deploy.sh