Skip to content

deploy-ducksmanager #80

deploy-ducksmanager

deploy-ducksmanager #80

name: deploy-ducksmanager
on:
workflow_dispatch:
push:
paths:
- ".github/workflows/deploy-ducksmanager.yml"
- "apps/web/**"
- "pnpm-lock.yaml"
branches:
- "master"
jobs:
deploy-dm:
runs-on: ubuntu-latest
environment: production
steps:
- name: Check out repository
uses: actions/checkout@master
with:
submodules: recursive
- name: Download web .env file
uses: nicklasfrahm/scp-action@main
with:
direction: download
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: /home/bperel/workspace/DucksManager2/apps/web/.env.prod.local
target: apps/web/.env
- name: Download api .env file
uses: nicklasfrahm/scp-action@main
with:
direction: download
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: /home/bperel/workspace/DucksManager2/packages/api/.env.prod.local
target: packages/api/.env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: bperel
password: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
- name: Build and push web
uses: docker/build-push-action@v5
with:
context: .
file: apps/web/Dockerfile
platforms: linux/x86_64
push: true
target: web
cache-from: type=registry,ref=ghcr.io/bperel/ducksmanager-web:buildcache
cache-to: type=registry,ref=ghcr.io/bperel/ducksmanager-web:buildcache,mode=max
tags: |
ghcr.io/bperel/ducksmanager-web:latest
- name: Build and push api
uses: docker/build-push-action@v5
with:
context: .
file: apps/web/Dockerfile
platforms: linux/x86_64
push: true
target: api
cache-from: type=registry,ref=ghcr.io/bperel/ducksmanager-api:buildcache
cache-to: type=registry,ref=ghcr.io/bperel/ducksmanager-api:buildcache,mode=max
tags: |
ghcr.io/bperel/ducksmanager-api:latest
- name: Upload docker-compose.yml file
uses: nicklasfrahm/[email protected]
with:
direction: upload
host: ${{ secrets.PRODUCTION_SSH_HOST }}
fingerprint: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: apps/web/docker-compose.yml
target: /home/bperel/workspace/DucksManager2/docker-compose.yml
- name: Recreate container
uses: appleboy/[email protected]
env:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
command_timeout: 2m
envs: DOCKER_REGISTRY_TOKEN_DM
script: |
cd workspace/DucksManager2
echo `grep GITHUB_TOKEN .env | cut -d'=' -f2` | docker login ghcr.io -u bperel --password-stdin
docker compose pull && docker compose up -d --force-recreate web api sentry-relay