Skip to content

Build & Deploy

Build & Deploy #5

Workflow file for this run

name: Build & Deploy
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types: [completed]
jobs:
build-push:
if: >-
github.repository == 'readium/speech-server' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ github.event.workflow_run.head_sha }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:latest
cache-to: type=inline
deploy:
needs: build-push
runs-on: ubuntu-latest
steps:
- name: Deploy to GCP VM
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.GCP_VM_HOST }}
username: ${{ secrets.GCP_VM_USER }}
key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
script: |
cd ~/speech-server
git pull
docker compose pull app
docker compose up -d --no-build app
docker compose restart nginx
docker image prune -f