tech: add async runner celery #42
This file contains hidden or 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 to Scaleway | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: ${{ github.ref_name }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up SSH | |
| uses: webfactory/ssh-agent@v0.5.3 | |
| with: | |
| ssh-private-key: ${{ secrets.SCW_SSH_KEY }} | |
| - name: Deploy to Scaleway | |
| env: | |
| SCW_HOST: ${{ secrets.SCW_HOST }} | |
| SCW_USER: ${{ secrets.SCW_USER }} | |
| run: | | |
| ssh -o StrictHostKeyChecking=no $SCW_USER@$SCW_HOST << 'EOF' | |
| set -e # This will make the script exit immediately if any command fails | |
| cd /home/${{ secrets.SCW_USER }}/aigle-api || exit 1 | |
| # Fetch and reset to remote branch | |
| git fetch origin ${{ github.ref_name }} || exit 1 | |
| git reset --hard origin/${{ github.ref_name }} || exit 1 | |
| set -a # Enable auto-export of variables | |
| source .env || exit 1 | |
| set +a # Disable auto-export of variables | |
| sudo apt update && sudo apt -y upgrade || exit 1 | |
| xargs -a Aptfile sudo apt install -y || exit 1 | |
| xargs -a Aptfile sudo apt install -y || exit 1 | |
| sudo systemctl start redis-server || exit 1 | |
| sudo systemctl enable redis-server || exit 1 | |
| source venv/bin/activate || exit 1 | |
| python -m pip install -r requirements.txt || exit 1 | |
| python manage.py migrate || exit 1 | |
| celery -A aigle worker --loglevel=info || exit 1 | |
| sudo systemctl restart gunicorn_aigle || exit 1 | |
| echo "Deployment completed successfully!" | |
| EOF | |
| # Check the exit status of the SSH command | |
| if [ $? -ne 0 ]; then | |
| echo "Deployment failed!" | |
| exit 1 | |
| fi |