Skip to content

Change docker compose to yaml cause coolify doesn't like yml #37

Change docker compose to yaml cause coolify doesn't like yml

Change docker compose to yaml cause coolify doesn't like yml #37

Workflow file for this run

name: Deploy Prod
# -----
# This workflow will run whenever changes are pushed to main
# -----
on:
push:
branches:
- main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
jobs:
deploy:
name: Deploy
environment: prod
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- uses: actions/download-artifact@v2
- name: Copy bleck into id rsa
run: install -m 600 -D /dev/null ~/.ssh/id_rsa
- name: See if env vars propagated
run: echo "$SSH_HOST"
- name: Copy private key into keyfile
run: echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- name: Scan into known hosts
run: ssh-keyscan -H -p "$SSH_PORT" "$SSH_HOST" > ~/.ssh/known_hosts
- name: Create env file
run: touch ${{ github.workspace}}/.env
- name: Write in prod env
run: echo ENV=PROD >> ${{ github.workspace }}/.env
- name: Write in postgres password
run: echo POSTGRES_PASSWORD="$POSTGRES_PASSWORD" >> ${{ github.workspace }}/.env
- name: Write in postgres username
run: echo POSTGRES_USER="$POSTGRES_USER" >> ${{ github.workspace }}/.env
- name: Write in postgres db name
run: echo POSTGRES_DB="$POSTGRES_DB" >> ${{ github.workspace }}/.env
- name: Write in postgres database url
run: echo DATABASE_URL= postgresql://"$POSTGRES_USER":"$POSTGRES_PASSWORD"@psqldbgame:5432/"$POSTGRES_DB" >> ${{ github.workspace }}/.env
- name: Send updated source to our VPS
run: rsync -rav --delete -e 'ssh -p 3732' ${{ github.workspace }}/ "$SSH_USERNAME"@"$SSH_HOST":/home/"$SSH_USERNAME"/src/game-remix-guesser-backend/
- name: Tear down old docker
run: ssh -p 3732 "${SSH_USERNAME}"@"${SSH_HOST}" "cd src/game-remix-guesser-backend && docker compose down --rmi all"
- name: Start up new docker
run: ssh -p 3732 "${SSH_USERNAME}"@"${SSH_HOST}" "cd src/game-remix-guesser-backend && docker compose -f docker-compose.prod.yml up -d"