Skip to content

🏗 Deploy to Scalingo #925

🏗 Deploy to Scalingo

🏗 Deploy to Scalingo #925

name: 🏗 Deploy to Scalingo
on:
push:
branches:
- main
schedule:
- cron: '0 11 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
concurrency: "deploy-to-scalingo"
environment: Scalingo
env:
SCALINGO_APP_NAME: ${{ secrets.SCALINGO_APP_NAME }}
SCALINGO_GIT_URL: ${{ secrets.SCALINGO_GIT_URL }}
SCALINGO_POSTGRESQL_ADDON_ID: ${{ secrets.SCALINGO_POSTGRESQL_ADDON_ID }}
SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup SSH
run: |
mkdir ~/.ssh
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -N "" -C "gihub_workflow"
chmod 600 ~/.ssh/id_ed25519
echo "$SSH_KNOWN_HOSTS" >~/.ssh/known_hosts
- name: Install Scalingo CLI
run: curl -O https://cli-dl.scalingo.com/install && bash install
- name: Login to Scalingo
run: scalingo login --api-token $SCALINGO_API_TOKEN
- name: Clean previous SSH public key if exists
run: scalingo keys-remove inclusion-connect-prod-deploy-pour-push-github
continue-on-error: true
- name: Add SSH public key
run: scalingo keys-add inclusion-connect-prod-deploy-pour-push-github ~/.ssh/id_ed25519.pub
- name: Restore latest database backup
run: >-
scalingo \
--region osc-secnum-fr1 \
--app $SCALINGO_APP_NAME \
run \
--size S \
python restore-backup.py
- name: Deploy to Scalingo
run: git push $SCALINGO_GIT_URL HEAD:main --force
- name: Remove SSH public key
run: scalingo keys-remove inclusion-connect-prod-deploy-pour-push-github
- name: Failover
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
scalingo --region osc-secnum-fr1 --app $SCALINGO_APP_NAME addons-upgrade $SCALINGO_POSTGRESQL_ADDON_ID postgresql-starter-1024
scalingo --region osc-secnum-fr1 --app $SCALINGO_APP_NAME scale web:1:XL