diff --git a/.github/workflows/jenkins-deploy.yml b/.github/workflows/jenkins-deploy.yml new file mode 100644 index 0000000..e2eb589 --- /dev/null +++ b/.github/workflows/jenkins-deploy.yml @@ -0,0 +1,16 @@ +name: Deploy on server +on: + workflow_dispatch: + +jobs: + Deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - name: Trigger Jenkins jobs + uses: appleboy/jenkins-action@master + with: + url: "http://ci.saccada.xyz" + user: ${{ env.JENKINS_USERNAME }} + token: ${{ secrets.JENKINS_TOKEN }} + job: "Deploy Django application" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..4891947 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,36 @@ +pipeline { + agent any + + + stages { + stage('Hello') { + steps { + echo 'Hello from Jenkins' + } + } + stage('Connect to server') { + steps { + withCredentials([ + sshUserPrivateKey( + credentialsId: '73d234d2-3f9d-44e9-97fc-b6317070b462', + keyFileVariable: 'SSH_PRIVATE_KEY' + ) + ]) { + sh '''#!/bin/bash + ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << EOF + cd ~/ws/django-example-app + git pull --rebase + docker compose pull + docker compose down + docker compose up -d + ''' + } + } + } + } + post { + always { + sleep 5 + } + } +} diff --git a/README.md b/README.md index f7d5d35..9100c43 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Application made by django's instruction for **DevOps** education purposes # Pylint -![pylint](https://img.shields.io/badge/PyLint-6.20-orange?logo=python&logoColor=white) +![pylint](https://img.shields.io/badge/PyLint-6.22-orange?logo=python&logoColor=white) diff --git a/mysite/settings.py b/mysite/settings.py index 790e7aa..bc8a238 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -26,6 +26,7 @@ SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False +CSRF_TRUSTED_ORIGINS = ["https://app.saccada.xyz"] ALLOWED_HOSTS = ["localhost", "app.saccada.xyz"]