Deploy #5
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 | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Add SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.HELIOS_SSH }}" > ~/.ssh/helios_ssh | |
chmod 600 ~/.ssh/helios_ssh | |
- name: Form environment variables | |
run: | | |
echo "GHCR_PAT=\"${{ secrets.GHCR_PAT }}\"" >> .env | |
echo "MASTER_BACKEND_PORT=\"${MASTER_BACKEND_PORT}\"" >> .env | |
echo "MASTER_BACKEND_URL=\"${MASTER_BACKEND_URL}\"" >> .env | |
echo "MASTER_METRICS_PORT=\"${MASTER_METRICS_PORT}\"" >> .env | |
echo "MASTER_METRICS_URL=\"${MASTER_METRICS_URL}\"" >> .env | |
echo "DATABASE_PORT=\"${DATABASE_PORT}\"" >> .env | |
echo "DATABASE_NAME=\"${DATABASE_NAME}\"" >> .env | |
echo "DATABASE_USER=\"${DATABASE_USER}\"" >> .env | |
echo "DATABASE_PASSWORD=\"${DATABASE_PASSWORD}\"" >> .env | |
echo "DATABASE_HOST=\"${DATABASE_HOST}\"" >> .env | |
echo "DATABASE_URL=\"${DATABASE_URL}\"" >> .env | |
echo "JWT_ACCESS_SECRET=\"${JWT_ACCESS_SECRET}\"" >> .env | |
echo "JWT_REFRESH_SECRET=\"${JWT_REFRESH_SECRET}\"" >> .env | |
echo "RUST_ENV=\"${RUST_ENV}\"" >> .env | |
echo "HELIOS_DOMAIN=\"${HELIOS_DOMAIN}\"" >> .env | |
echo "DO_AUTH_TOKEN=\"${DO_AUTH_TOKEN}\"" >> .env | |
echo "TRAEFIK_AUTH=\"${TRAEFIK_AUTH}\"" >> .env | |
echo "GRAFANA_USER=\"${GRAFANA_USER}\"" >> .env | |
echo "GRAFANA_PASSWORD=\"${GRAFANA_PASSWORD}\"" >> .env | |
- name: Setup to DigitalOcean | |
run: | | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "echo ${{ secrets.GHCR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin" | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "rm -f docker-compose.yml" | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "rm -f .env" | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "rm -rf traefik/" | |
scp -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -P ${{ secrets.SSH_PORT }} docker-compose.yml ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/docker-compose.yml | |
scp -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -P ${{ secrets.SSH_PORT }} .env ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/.env | |
scp -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -P ${{ secrets.SSH_PORT }} -r traefik/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/traefik/ | |
- name: Deploy to DigitalOcean | |
run: | | |
ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker compose down" | |
ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker compose pull" | |
ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker compose up -d" |