hotfix: 소셜 주소 변경 #17
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: CD | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: dykkim/muneo | |
| tags: | | |
| type=raw,value=latest | |
| type=sha,format=short | |
| - name: Build and push image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Copy deploy files to EC2 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| port: ${{ secrets.EC2_PORT }} | |
| source: "docker-compose.yml,nginx/conf.d/default.conf" | |
| target: ${{ secrets.EC2_DEPLOY_PATH }} | |
| strip_components: 0 | |
| - name: Deploy on EC2 | |
| uses: appleboy/ssh-action@v1.0.3 | |
| env: | |
| DEPLOY_PATH: ${{ secrets.EC2_DEPLOY_PATH }} | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| DOCKERHUB_IMAGE: dykkim/muneo | |
| APP_ENV_PROD: ${{ secrets.APP_ENV_PROD }} | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| port: ${{ secrets.EC2_PORT }} | |
| envs: DEPLOY_PATH,DOCKERHUB_USERNAME,DOCKERHUB_TOKEN,DOCKERHUB_IMAGE,APP_ENV_PROD | |
| script_stop: true | |
| script: | | |
| set -e | |
| sudo systemctl enable --now docker || true | |
| mkdir -p "${DEPLOY_PATH}" | |
| cd "${DEPLOY_PATH}" | |
| mkdir -p nginx/conf.d | |
| printf "%s" "${APP_ENV_PROD}" > .env | |
| { | |
| echo "" | |
| echo "DOCKERHUB_IMAGE=${DOCKERHUB_IMAGE}" | |
| echo "IMAGE_TAG=latest" | |
| } >> .env | |
| echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin | |
| docker compose pull app redis nginx | |
| docker compose up -d --remove-orphans app redis nginx | |
| docker image prune -f |