Created
November 7, 2024 12:01
-
-
Save arynyklas/cd90089ea14ea44671c1ed3f90682b8e to your computer and use it in GitHub Desktop.
Auto deploy application using Github Workflow
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 Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Create SSH Key File | |
run: | | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /tmp/deploy_key | |
chmod 600 /tmp/deploy_key | |
- name: Deploy to Server | |
run: | | |
ssh -o StrictHostKeyChecking=no -i /tmp/deploy_key -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF' | |
cd /home/app/ | |
git reset --hard | |
git pull origin main | |
source .venv/bin/activate | |
pip install -r requirements.txt > /dev/null | |
sudo /usr/local/bin/restart-app.sh && echo "Deployed successfully" | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment