Deploy Docker Image #42
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: Deploy Docker Image | |
on: | |
workflow_run: | |
workflows: ["Build and Push"] | |
branches: | |
- main | |
- develop | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ (github.ref == 'refs/heads/main') && 'PROMPT-Prod' || (github.ref == 'refs/heads/develop') && 'PROMPT-Dev' }} | |
url: 'https://${{ vars.VM_HOST }}' | |
steps: | |
- name: SSH to VM and Execute Docker-Compose Down | |
uses: appleboy/ssh-action@v1.0.3 | |
continue-on-error: true | |
with: | |
host: ${{ vars.VM_HOST }} | |
username: ${{ vars.VM_USERNAME }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
script: | | |
docker compose -f tease/docker-compose.prod.yml --env-file=.env.prod down --remove-orphans --rmi all | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Copy Docker Compose File From Repo to VM Host | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ vars.VM_HOST }} | |
username: ${{ vars.VM_USERNAME }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
source: "./docker-compose.prod.yml" | |
target: /home/${{ vars.VM_USERNAME }}/tease | |
- name: SSH to VM and Execute Docker-Compose Up | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ vars.VM_HOST }} | |
username: ${{ vars.VM_USERNAME }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
script: | | |
docker compose -f tease/docker-compose.prod.yml --env-file=.env.prod up --pull=always -d |