Skip to content

Update docker-compose.yml to restart on failure #10

Update docker-compose.yml to restart on failure

Update docker-compose.yml to restart on failure #10

Workflow file for this run

name: Build and Deploy to Cloud VM
on:
push:
branches:
- "main"
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Auth Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Get SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# Build the Docker image
- name: Build
run: |-
docker build --tag "cornellappdev/big-red-bot:${{ steps.vars.outputs.sha_short }}" .
# Push the Docker image to Google Container Registry
- name: Publish
run: |-
docker push "cornellappdev/big-red-bot:${{ steps.vars.outputs.sha_short }}"
- name: SSH & Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
export SLACK_BOT_IMG_TAG="${{ steps.vars.outputs.sha_short }}"
docker stop big-red-bot-backend-web-1
docker rm big-red-bot-backend-web-1
yes | sudo docker container prune
yes | sudo docker system prune
cd slackbot
docker compose -p big-red-bot-backend up -d