From a9df789b04d8ef81ffefffa8fadfbfd1bd3cf9d2 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 14:43:36 +0300 Subject: [PATCH 01/24] add trusted origins --- mysite/settings.py | 1 + 1 file changed, 1 insertion(+) 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"] From 6b4e12697fb7cc3cdc64018b292e19524225e470 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 11:24:56 +0300 Subject: [PATCH 02/24] init Jenkinsfile --- Jenkinsfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..b2355d7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,11 @@ +pipeline { + agent any + + stages { + stage('Hello') { + steps { + echo 'Hello from Jenkins' + } + } + } +} From 92498c074cf8727ddf3d9fde7178c34c5a468957 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 11:52:38 +0300 Subject: [PATCH 03/24] init ssh command --- Jenkinsfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index b2355d7..ddce28a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,35 @@ +def remote=[:] +remote.name = 'saccada.xyz' +remote.host = 'saccada.xyz' +remote.allowAnyHosts = true + + pipeline { agent any + environment { + CREDS=credentials('73d234d2-3f9d-44e9-97fc-b6317070b462') + } + stages { stage('Hello') { steps { echo 'Hello from Jenkins' } } + stage('Connect to server') { + steps { + script { + remote.user = env.CREDS_USR + remote.password = env.CREDS_PSW + } + sshCommand(remote: remote, command: "find ~/ws") + } + } + } + post { + always { + sleep 5 + } } } From 0169c28170c70f7a9f88482f168bc1fa96154517 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 11:58:45 +0300 Subject: [PATCH 04/24] make new ssh --- Jenkinsfile | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ddce28a..ecc7337 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,15 +1,6 @@ -def remote=[:] -remote.name = 'saccada.xyz' -remote.host = 'saccada.xyz' -remote.allowAnyHosts = true - - pipeline { agent any - environment { - CREDS=credentials('73d234d2-3f9d-44e9-97fc-b6317070b462') - } stages { stage('Hello') { @@ -19,11 +10,14 @@ pipeline { } stage('Connect to server') { steps { - script { - remote.user = env.CREDS_USR - remote.password = env.CREDS_PSW + withCredentials([ + sshUserPrivateKey( + credentialsId: '73d234d2-3f9d-44e9-97fc-b6317070b462', + keyFileVariable: 'SSH_PRIVATE_KEY' + ) + ]) { + sh "ssh -i $SSH_PRIVATE_KEY saccada@saccada.xyz 'find ~/ws'" } - sshCommand(remote: remote, command: "find ~/ws") } } } From ef2741fccbf53fa1db80f35a7a03c744ffadd786 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:00:23 +0300 Subject: [PATCH 05/24] add colons --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ecc7337..f5d1f0e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh "ssh -i $SSH_PRIVATE_KEY saccada@saccada.xyz 'find ~/ws'" + sh "ssh -i \"$SSH_PRIVATE_KEY\" saccada@saccada.xyz 'find ~/ws'" } } } From df31f4672b15c332cafadcfa2cc1e3125bc5b6cf Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:01:04 +0300 Subject: [PATCH 06/24] add port --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f5d1f0e..20e1f63 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh "ssh -i \"$SSH_PRIVATE_KEY\" saccada@saccada.xyz 'find ~/ws'" + sh "ssh -i \"$SSH_PRIVATE_KEY\" -p 2222 saccada@saccada.xyz 'find ~/ws'" } } } From 1a3bfcad8517bfd134b94266bd8735863dc414f6 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:03:03 +0300 Subject: [PATCH 07/24] privcacy fixes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 20e1f63..022816f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh "ssh -i \"$SSH_PRIVATE_KEY\" -p 2222 saccada@saccada.xyz 'find ~/ws'" + sh('ssh -i $SSH_PRIVATE_KEY -p 2222 saccada@saccada.xyz "find ~/ws"') } } } From a0dd1e91db7bbee7075875d615e709e2f2340c3d Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:04:30 +0300 Subject: [PATCH 08/24] fix --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 022816f..4286b9f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh('ssh -i $SSH_PRIVATE_KEY -p 2222 saccada@saccada.xyz "find ~/ws"') + sh('ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz "find ~/ws"') } } } From 3593e52eec1cd0473a1c2f2929b77bb60727ba56 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:10:09 +0300 Subject: [PATCH 09/24] fix https://serverfault.com/questions/880938/jenkins-host-key-verification-failed --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4286b9f..fd52b21 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh('ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz "find ~/ws"') + sh('ssh -i "$SSH_PRIVATE_KEY" -p 2222 -o StrictHostKeyChecking=no saccada@saccada.xyz "find ~/ws"') } } } From 90d5d05be333b095b0c3cc915bd3924e346e585b Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:11:52 +0300 Subject: [PATCH 10/24] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fd52b21..4286b9f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh('ssh -i "$SSH_PRIVATE_KEY" -p 2222 -o StrictHostKeyChecking=no saccada@saccada.xyz "find ~/ws"') + sh('ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz "find ~/ws"') } } } From 316ab869d8caedfc87a86392207bf9a950328bb7 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:13:11 +0300 Subject: [PATCH 11/24] test 2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4286b9f..b2d694b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh('ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz "find ~/ws"') + sh 'ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz "find ~/ws"' } } } From ebe164c861657b970e04845596de6facfd200ca0 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:15:05 +0300 Subject: [PATCH 12/24] add docker compose step --- Jenkinsfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b2d694b..b77bc69 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,14 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh 'ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz "find ~/ws"' + sh '''ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz < Date: Mon, 9 Jun 2025 12:15:31 +0300 Subject: [PATCH 13/24] fix typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b77bc69..01bc598 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { ]) { sh '''ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz < Date: Mon, 9 Jun 2025 12:16:53 +0300 Subject: [PATCH 14/24] test EOF --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 01bc598..34d9d4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh '''ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz < Date: Mon, 9 Jun 2025 12:18:30 +0300 Subject: [PATCH 15/24] fix --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34d9d4d..bf04f9e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,7 @@ pipeline { docker compose pull docker compose down docker compose up -d - EOF - ''' + EOF''' } } } From 927985d692ea09a0f1a6f6c5713ab5d24bfc3fe0 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:21:41 +0300 Subject: [PATCH 16/24] add bash --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf04f9e..368e4c9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,8 @@ pipeline { keyFileVariable: 'SSH_PRIVATE_KEY' ) ]) { - sh '''ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << EOF + 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 From 3dffd8505a827670417fbb8cc010281af6796852 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:23:30 +0300 Subject: [PATCH 17/24] _EOF_ --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 368e4c9..4100392 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,13 +17,13 @@ pipeline { ) ]) { sh '''#!/bin/bash - ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << EOF + 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 - EOF''' + _EOF_''' } } } From 5ba1fcccd11074db21e9df6c5a8a5c85b7058a86 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:25:05 +0300 Subject: [PATCH 18/24] test --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4100392..7655363 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,13 +17,13 @@ pipeline { ) ]) { 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 - _EOF_''' + 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 + _EOF_''' } } } From bc8f4a5c98a7690369a24662785a4dc6f26303a0 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:27:13 +0300 Subject: [PATCH 19/24] quote EOF --- Jenkinsfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7655363..2deece8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,13 +17,14 @@ pipeline { ) ]) { sh '''#!/bin/bash - ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz <<- _EOF_ + 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 - _EOF_''' + ls -la + # docker compose pull + # docker compose down + # docker compose up -d + 'EOF'''' } } } From 0806e2f99d8c5e1b3ed65d55517258ac167c539b Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:27:37 +0300 Subject: [PATCH 20/24] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2deece8..41cb1ed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ pipeline { # docker compose pull # docker compose down # docker compose up -d - 'EOF'''' + EOF''' } } } From 28a2772714ab281d282b18fc5b6167a3935b0c7a Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:29:00 +0300 Subject: [PATCH 21/24] try this --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 41cb1ed..c66311e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,14 +17,14 @@ pipeline { ) ]) { sh '''#!/bin/bash - ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << 'EOF' + ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << EOF cd ~/ws/django-example-app git pull --rebase ls -la # docker compose pull # docker compose down # docker compose up -d - EOF''' + ''' } } } From 9cb31912febed78d0437de547529a9cd519e51c9 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:29:29 +0300 Subject: [PATCH 22/24] full pipeline --- Jenkinsfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c66311e..4891947 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,10 +20,9 @@ pipeline { ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << EOF cd ~/ws/django-example-app git pull --rebase - ls -la - # docker compose pull - # docker compose down - # docker compose up -d + docker compose pull + docker compose down + docker compose up -d ''' } } From a2e446c5b4c8e35cba5bbd66374a29c08f4adfd0 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Mon, 9 Jun 2025 12:48:04 +0300 Subject: [PATCH 23/24] add jenkins manual deploy --- .github/workflows/jenkins-deploy.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/jenkins-deploy.yml 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" From ca3526143257c034929a41dc577628b1c2bb8b8f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 09:50:57 +0000 Subject: [PATCH 24/24] Updated pylint badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)