deploy-dumili #29
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-dumili | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- ".github/workflows/deploy-dumili.yml" | |
- "apps/dumili/**" | |
- "pnpm-lock.yaml" | |
branches: | |
- "master" | |
jobs: | |
deploy-dumili: | |
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.prod.local | |
- name: Download .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/dumili/.env.prod.local | |
target: apps/dumili/api/.env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: | | |
image=moby/buildkit:v0.12.0 | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: bperel | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }} | |
- name: Build and push app | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/x86_64 | |
push: true | |
target: dumili | |
cache-from: type=registry,ref=ghcr.io/bperel/dumili-app:buildcache | |
cache-to: type=registry,ref=ghcr.io/bperel/dumili-app:buildcache,mode=max | |
tags: | | |
ghcr.io/bperel/dumili-app:latest | |
- name: Build and push api | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/x86_64 | |
push: true | |
target: dumili-api | |
cache-from: type=registry,ref=ghcr.io/bperel/dumili-api:buildcache | |
cache-to: type=registry,ref=ghcr.io/bperel/dumili-api:buildcache,mode=max | |
tags: | | |
ghcr.io/bperel/dumili-api:latest | |
- name: Build and push kumiko | |
uses: docker/build-push-action@v3 | |
with: | |
context: apps/dumili/kumiko | |
platforms: linux/x86_64 | |
push: true | |
cache-from: type=registry,ref=ghcr.io/bperel/kumiko:buildcache | |
cache-to: type=registry,ref=ghcr.io/bperel/kumiko:buildcache,mode=max | |
tags: | | |
ghcr.io/bperel/kumiko:latest | |
- name: Build and push paddleocr | |
uses: docker/build-push-action@v3 | |
with: | |
context: apps/dumili/paddleocr | |
platforms: linux/x86_64 | |
push: true | |
cache-from: type=registry,ref=ghcr.io/bperel/paddleocr:buildcache | |
cache-to: type=registry,ref=ghcr.io/bperel/paddleocr:buildcache,mode=max | |
tags: | | |
ghcr.io/bperel/paddleocr: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/dumili/docker-compose.yml | |
target: /home/bperel/workspace/dumili/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_DUMILI | |
script: | | |
cd workspace/dumili | |
echo `grep GITHUB_TOKEN .env.prod.local | cut -d'=' -f2` | docker login ghcr.io -u bperel --password-stdin | |
docker compose pull && docker compose up -d --force-recreate |