Pull New Image & Restart Container #37
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: Pull New Image & Restart Container | |
on: | |
workflow_run: | |
workflows: ["Build and Publish", "Build and Publish - Dev Build"] | |
types: | |
- completed | |
jobs: | |
check_workflow: | |
runs-on: ubuntu-latest | |
outputs: | |
is_dev: ${{ steps.check_dev.outputs.is_dev }} | |
steps: | |
- name: Check which workflow was run | |
id: check_dev | |
run: echo "::set-output name=is_dev::${{ github.event.workflow_run.name == 'Build and Publish - Dev Build' }}" | |
deploy: | |
needs: check_workflow | |
runs-on: ubuntu-latest | |
steps: | |
- name: Execute SSH commands on remote server for Prod | |
if: needs.check_workflow.outputs.is_dev == 'false' | |
uses: JimCronqvist/action-ssh@master | |
with: | |
hosts: ${{ secrets.HOST }} | |
privateKey: ${{ secrets.PRIVATE_KEY }} | |
envs: DOCKER_NETWORK_STACK=${{ secrets.DOCKER_NETWORK_STACK }} | |
command: | | |
docker stop wheretolivedotla || true && \ | |
docker rm wheretolivedotla || true && \ | |
docker run -d --pull=always --name wheretolivedotla --network $DOCKER_NETWORK_STACK --hostname wheretolivedotla strayingfromthepath/larentals | |
- name: Execute SSH commands on remote server for Dev | |
if: needs.check_workflow.outputs.is_dev == 'true' | |
uses: JimCronqvist/action-ssh@master | |
with: | |
hosts: ${{ secrets.HOST }} | |
privateKey: ${{ secrets.PRIVATE_KEY }} | |
envs: DOCKER_NETWORK_STACK=${{ secrets.DOCKER_NETWORK_STACK }} | |
command: | | |
docker stop wheretolivedotla || true && \ | |
docker rm wheretolivedotla || true && \ | |
docker run -d --pull=always --name wheretolivedotla-dev --network $DOCKER_NETWORK_STACK --hostname wheretolivedotla-dev strayingfromthepath/larentals:dev |