name: ordr deploy
run-name: ${{ gitea.actor }} is deploying ordr
on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Create SSH key
        run: |
          mkdir -p ~/.ssh/
          echo "$SSH_PRIVATE_KEY" > ~/private.key
          sudo chmod 600 ~/private.key
          echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
        shell: bash
        env:
          SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
          SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}}
          SSH_KEY_PATH: ~/private.key
      - name: Up the services
        run: |
          ssh -i $SSH_KEY_PATH ${{vars.SERVER_SSH_URL}} "ssh Conways "cd /home/shared/ordr && git pull && echo ${${{secrets.SSH_PASSWORD}}} | sudo -S docker compose down && echo ${${{secrets.SSH_PASSWORD}}} | sudo -S docker compose up --build --force-recreate --detach""