Refactor/redis issue generate (#143) #95
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: 애자일허브 backend PROD CD | |
env: | |
DOCKER_HUB_REPOSITORY: ${{ secrets.DOCKERHUB_USERNAME }}/agilehub-backend | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- develop | |
paths: | |
- "src/**" | |
jobs: | |
backend-docker-build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Docker Buildx를 설정한다 | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
# Dockerfile이 있는 위치 | |
file: ./Dockerfile | |
# Dockerfile의 이름 | |
push: true | |
# 이미지를 레지스트리에 푸시 | |
tags: ${{ env.DOCKER_HUB_REPOSITORY }}:${{ github.sha }} | |
platforms: linux/amd64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: WAS인스턴스 접속 및 애플리케이션 실행 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.NCP_HOST }} | |
username: ${{ secrets.NCP_USERNAME }} | |
password: ${{ secrets.NCP_PASSWORD }} | |
key: ${{ secrets.NCP_PEM_KEY }} | |
port: 22 | |
script: | | |
docker rm -f agilehub-backend || true | |
docker pull ${{ env.DOCKER_HUB_REPOSITORY }}:${{ github.sha }} | |
docker run -v /var/log/backend:/app/logs \ | |
--env-file .env \ | |
-d -p 8080:8080 --name agilehub-backend ${{ env.DOCKER_HUB_REPOSITORY }}:${{ github.sha }} |