Feat/support unauthenticated menu (#1172) #145
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 Server | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- backend/** | |
- deployment/** | |
- frontend/** | |
- email-templates-generator/** | |
- .github/workflows/deploy-server.yml | |
jobs: | |
changes: | |
name: Check changes on Front end | |
runs-on: ubuntu-latest | |
outputs: | |
backend: ${{ steps.filter.outputs.backend}} | |
frontend: ${{ steps.filter.outputs.frontend }} | |
email-templates: ${{ steps.filter.outputs.email-templates }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
base: ${{ github.ref }} | |
filters: | | |
backend: | |
- 'backend/**' | |
frontend: | |
- 'frontend/**' | |
email-templates: | |
- 'email-templates-generator/**' | |
frontend-quality: | |
name: Test front end quality | |
needs: changes | |
if: ${{ needs.changes.outputs.frontend == 'true' }} | |
uses: ./.github/workflows/quality-frontend.yml | |
secrets: inherit | |
backend-quality: | |
name: Test Back End Quality | |
needs: changes | |
if: ${{ needs.changes.outputs.backend == 'true' }} | |
uses: ./.github/workflows/quality-backend.yml | |
secrets: inherit | |
email-templates-quality: | |
name: Test Email Templates Quality | |
needs: changes | |
if: ${{ needs.changes.outputs.email-templates == 'true' }} | |
uses: ./.github/workflows/quality-email-templates.yml | |
secrets: inherit | |
frontend-build: | |
name: Build front end | |
needs: frontend-quality | |
uses: ./.github/workflows/build-frontend.yml | |
with: | |
target-directory: "nantralPlatform" | |
secrets: inherit | |
email-templates-build: | |
name: Build email templates | |
needs: email-templates-quality | |
uses: ./.github/workflows/build-email-templates.yml | |
with: | |
target-directory: "nantralPlatform" | |
secrets: inherit | |
backup-database: | |
name: Create a backup of the database | |
runs-on: ubuntu-latest | |
steps: | |
- name: Backup before deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.INSTANCE_ADDRESS }} | |
username: "ubuntu" | |
key: ${{ secrets.SSH_KEY_DEPLOY }} | |
script: | | |
cd nantralPlatform/deployment/scripts | |
sudo apt-get install python3-psycopg2 -y | |
python3 -m venv env | |
source env/bin/activate | |
pip install -r requirements.txt | |
python3 db_backup.py | |
deactivate | |
rm -r env | |
deploy: | |
name: Deploy on VPS | |
needs: | |
[frontend-build, email-templates-build, backend-quality, backup-database] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to the VPS | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.INSTANCE_ADDRESS }} | |
username: "ubuntu" | |
key: ${{ secrets.SSH_KEY_DEPLOY }} | |
script: | | |
cd nantralPlatform/deployment | |
git pull | |
sudo cp /etc/letsencrypt/live/nantral-platform.fr/privkey.pem /home/ubuntu/nantralPlatform/deployment/certs/key.pem | |
sudo cp /etc/letsencrypt/live/nantral-platform.fr/fullchain.pem /home/ubuntu/nantralPlatform/deployment/certs/cert.pem | |
sudo docker-compose -f docker-compose.yml -f docker-compose.prod.yml build --no-cache nginx backend celery celery-beat | |
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d |