Docker CI/CD - Deploy #30
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: Docker CI/CD - Deploy | |
| on: | |
| workflow_run: | |
| workflows: [ "Docker CI/CD" ] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| if: (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'develop') || (github.event_name == 'workflow_dispatch') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy via SSH | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| cd /home/ubuntu/mosu | |
| echo "${{ secrets.env }}" > .env.prod | |
| echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.prod | |
| sudo docker compose pull | |
| sudo docker compose down | |
| sudo docker compose -f docker-compose.yml --env-file .env.prod up -d --build |