Skip to content

danjac is deploying to production servers #188

danjac is deploying to production servers

danjac is deploying to production servers #188

name: radiofeed_deploy_production
run-name: ${{ github.actor }} is deploying to production servers
on:
workflow_dispatch:
branches:
- main
jobs:
run_checks:
uses: ./.github/workflows/checks.yml
build_docker:
needs: run_checks
uses: ./.github/workflows/docker.yml
secrets: inherit
deploy_cron_scheduler:
runs-on: ubuntu-latest
needs: build_docker
steps:
- name: Cloning repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy to cron scheduler
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.CRON_SCHEDULER_IP }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker compose --project-directory ${{ secrets.PROJECT_DIR }} pull
docker compose --project-directory ${{ secrets.PROJECT_DIR }} run --rm django ./release.sh
docker system prune -f
deploy_app_servers:
runs-on: ubuntu-latest
needs: deploy_cron_scheduler
strategy:
matrix:
# list of references in JSON array e.g. ["APP_SERVER_1", "APP_SERVER_2"]
# each reference should be value in secrets e.g. APP_SERVER_1=169.0.0.1
server_ip: ${{ fromJson(vars.APP_SERVER_IP_REFS) }}
steps:
- name: Cloning repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy to app server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets[matrix.server_ip] }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker compose --project-directory ${{ secrets.PROJECT_DIR }} pull
docker compose --project-directory ${{ secrets.PROJECT_DIR }} up -d --remove-orphans
docker system prune -f