feature: caffeine 캐싱 적용 #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
name: main branch cd | |
on: | |
push: | |
branches: | |
- "main" | |
env: | |
MAIN_YML_PATH: ./src/main/resources/application.yml | |
PROD_YML_PATH: ./src/main/resources/application-prod.yml | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: application.yml setting | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ${{ env.MAIN_YML_PATH }} | |
env: | |
coolsms.api.key: ${{ secrets.COOLSMS_API_KEY }} | |
coolsms.api.secret: ${{ secrets.COOLSMS_API_SECRET }} | |
coolsms.api.from-number: ${{ secrets.COOLSMS_API_FROM_NUMBER }} | |
- name: application-prod.yml setting | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ${{ env.PROD_YML_PATH }} | |
env: | |
spring.datasource.url: ${{ secrets.RDS_URL }} | |
spring.datasource.username: ${{ secrets.PROD_DB_USERNAME }} | |
spring.datasource.password: ${{ secrets.PROD_DB_PASSWORD }} | |
- name: Docker build & push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -f Dockerfile_prod -t ${{ secrets.DOCKER_USERNAME }}/insurance_system_prod . | |
docker push ${{ secrets.DOCKER_USERNAME }}/insurance_system_prod | |
- name: Deploy EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST_IP }} | |
username: ubuntu | |
key: ${{ secrets.EC2_KEY }} | |
port: 22 | |
script: | | |
docker stop insurance_system_prod | |
docker rm insurance_system_prod | |
docker rmi choihyeok/insurance_system_prod | |
docker pull choihyeok/insurance_system_prod | |
docker run -d -p 8080:8080 --name insurance_system_prod choihyeok/insurance_system_prod |