Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Python 🐍 Deploy 🚀 #32

Python 🐍 Deploy 🚀

Python 🐍 Deploy 🚀 #32

Workflow file for this run

name: Python 🐍 Deploy 🚀
on:
workflow_run:
workflows: ["python-test"]
types:
- completed
workflow_dispatch:
defaults:
run:
shell: bash -l {0}
jobs:
deploy:
name: Deploy to server 🚀
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH Directory
run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
- name: Setup SSH Known Hosts
run: |
ssh-keyscan -t rsa ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Set up SSH Agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Copy files to server
run: |
rsync -vr --delete ${GITHUB_WORKSPACE} ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/home/${{ secrets.SSH_USER }}/sites/
- name: Compose up services
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} << 'EOF'
export POSTGRES_USER=${{ secrets.POSTGRES_USER }}
export POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
export POSTGRES_PORT=${{ secrets.POSTGRES_PORT }}
export POSTGRES_DB=${{ secrets.POSTGRES_DB }}
export API_KEY=${{ secrets.API_KEY }}
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
cd /home/${{ secrets.SSH_USER }}/sites/glossary-api/
docker compose -f compose.yaml up glossary_postgres glossary_web --build -d
EOF