update some actions #286
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: Django CI/CD Workflow | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
package-job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.x | |
deploy-job: | |
runs-on: ubuntu-latest | |
needs: [ package-job ] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Deploy | |
if: ${{ job.status != 'failure' }} | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
password: ${{ secrets.SERVER_PASSWORD }} | |
key: ${{ secrets.SECRET_KEY_GITHUB }} | |
script: | | |
cd /var/www/oqtepalavash/backend | |
git add oqtepa.sqlite3 media/* | |
git commit -m "update database" | |
git push | |
git pull | |
source venv/bin/activate | |
pip install -r requirements.txt | |
systemctl restart backend.service | |
systemctl reload nginx.service | |
- name: Stop Workflow on Error | |
if: ${{ job.status == 'failure' }} | |
run: exit 1 |