From 1ff450c37eadda20a7a7127b4333c7580a1b2ee7 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 00:30:41 +0300 Subject: [PATCH 01/39] fix naming --- compose.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index c6e96c4..fabc53e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,6 +1,7 @@ services: - app: - container_name: wtukatyr/django-example-app:latest + django-app: + image: wtukatyr/django-example-app:latest + container_name: django-app ports: - "8989:8000" depends_on: From ac5abef53fc6ce0791b2dd14e1a8fa02145bb6f3 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 00:32:21 +0300 Subject: [PATCH 02/39] dont run pipeline on push --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35d641e..2f1390c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,11 @@ name: CI-pipeline on: workflow_dispatch: - push: - branches: - - dev - pull_request: branches: - main + types: + - opened jobs: linters: From ed96af5c4f91d1a9506550e1d7c857220662f820 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 00:35:14 +0300 Subject: [PATCH 03/39] fix network name --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index fabc53e..bf2f264 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: env_file: - .env networks: - - proxy-common + - proxy_common db: image: postgres:14 restart: always From d9ca6a3887e9c2efda265dd471e145cb6f6b52b7 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 00:55:13 +0300 Subject: [PATCH 04/39] todo --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index bf2f264..820f09d 100644 --- a/compose.yaml +++ b/compose.yaml @@ -31,6 +31,7 @@ services: volumes: - pg-data:/var/lib/postgresql/data environment: + # TODO: fix env POSTGRES_USER: sa POSTGRES_PASSWORD: example POSTGRES_PORT: 5432 From 487f714d6b803562ae2b65ab7341db26ec67d116 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 11:02:25 +0300 Subject: [PATCH 05/39] add local network --- compose.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compose.yaml b/compose.yaml index 820f09d..91098b4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,9 @@ services: env_file: - .env networks: + - django_app_network - proxy_common + db: image: postgres:14 restart: always @@ -35,10 +37,15 @@ services: POSTGRES_USER: sa POSTGRES_PASSWORD: example POSTGRES_PORT: 5432 + networks: + - django_app_network + - proxy_common volumes: pg-data: networks: + django_app_network: + name: django_app_network proxy_common: external: true From 7942dc76617163e4cd9ae17f9afc662652fb7448 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 11:03:37 +0300 Subject: [PATCH 06/39] fix env --- compose.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compose.yaml b/compose.yaml index 91098b4..3183381 100644 --- a/compose.yaml +++ b/compose.yaml @@ -33,10 +33,11 @@ services: volumes: - pg-data:/var/lib/postgresql/data environment: - # TODO: fix env - POSTGRES_USER: sa - POSTGRES_PASSWORD: example - POSTGRES_PORT: 5432 + POSTGRES_USER: ${DATABASE_USERNAME} + POSTGRES_PASSWORD: ${DATABASE_PASSWORD} + POSTGRES_PORT: ${DATABASE_PORT} + env_file: + - .env networks: - django_app_network - proxy_common From e5e2c104f7697987212a7700e678c66c749e766a Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 11:17:08 +0300 Subject: [PATCH 07/39] remove fake job --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f1390c..87e903a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,9 +55,6 @@ jobs: Repository: ${{ github.repository }} See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} - - name: Check fail - run: echo "Unreachable" - - name: Notify in telegram about success uses: appleboy/telegram-action@master with: From 9d33e8ccbc8c95192c864c853ff93f9ff3cf871e Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 12:01:12 +0300 Subject: [PATCH 08/39] add saccada host --- mysite/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysite/settings.py b/mysite/settings.py index 0a5c1ea..24de387 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -26,7 +26,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ["localhost"] +ALLOWED_HOSTS = ["localhost", "app.saccada.xyz"] # Application definition From 52012032a32734f7e07c8e4e26fba96b1487bf11 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 12:02:08 +0300 Subject: [PATCH 09/39] add db name to postgres --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index 3183381..5cdfada 100644 --- a/compose.yaml +++ b/compose.yaml @@ -33,6 +33,7 @@ services: volumes: - pg-data:/var/lib/postgresql/data environment: + POSTGRES_DB: ${DATABASE_NAME} POSTGRES_USER: ${DATABASE_USERNAME} POSTGRES_PASSWORD: ${DATABASE_PASSWORD} POSTGRES_PORT: ${DATABASE_PORT} From 9ada62f718f83ab6a248b2f626c5eb558bad17bb Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:29:40 +0300 Subject: [PATCH 10/39] mount instead copy --- Dockerfile | 2 -- compose.yaml | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a6e1cf..cf734c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,6 @@ WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY ./mysite ./mysite -COPY ./polls ./polls COPY ./manage.py . RUN ./manage.py makemigrations diff --git a/compose.yaml b/compose.yaml index 5cdfada..16a506e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,6 +6,9 @@ services: - "8989:8000" depends_on: - db + volumes: + ./mysite:/app/mysite + ./polls:/app/polls environment: DATABASE_NAME: ${DATABASE_NAME} DATABASE_USERNAME: ${DATABASE_USERNAME} From 0a8bd3e4efb1679b3f671bc22a37665674381139 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:31:29 +0300 Subject: [PATCH 11/39] don't need a rebuild docker if files not touched --- .github/workflows/docker-build.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index fb33147..420f996 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -6,6 +6,10 @@ on: - main types: - closed + paths: + - Dockerfile + - requirements.txt + - manage.py jobs: build-and-push: From a41a37bca01f831386aa896e3f214e06f084caa9 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:32:46 +0300 Subject: [PATCH 12/39] fix compose --- compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 16a506e..ddb62be 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,8 +7,8 @@ services: depends_on: - db volumes: - ./mysite:/app/mysite - ./polls:/app/polls + - ./mysite:/app/mysite + - ./polls:/app/polls environment: DATABASE_NAME: ${DATABASE_NAME} DATABASE_USERNAME: ${DATABASE_USERNAME} From 1c9f69ee11d030a1e6cc9f57d9e154215885bd54 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:43:40 +0300 Subject: [PATCH 13/39] set debug to False --- mysite/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysite/settings.py b/mysite/settings.py index 24de387..790e7aa 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -24,7 +24,7 @@ SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False ALLOWED_HOSTS = ["localhost", "app.saccada.xyz"] From f81388e462f6e27c984bd48334199608dfe58b1f Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:43:56 +0300 Subject: [PATCH 14/39] make migrations in docker-entrypoint --- Dockerfile | 1 - docker-entrypoint.sh | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cf734c6..52cafbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY ./manage.py . -RUN ./manage.py makemigrations # RUN ./manage.py migrate COPY docker-entrypoint.sh . diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index b942dc5..48fa0a7 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,7 +4,10 @@ echo "Collect static files" python manage.py collectstatic --noinput + # Apply database migrations +echo "Make migrations" +RUN ./manage.py makemigrations echo "Apply database migrations" python manage.py migrate From ba83844c1ee2f9bffb345b541d5c4fd4daa0ae77 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:46:08 +0300 Subject: [PATCH 15/39] fix naming --- .github/workflows/docker-build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 420f996..dc0abd5 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -7,9 +7,9 @@ on: types: - closed paths: - - Dockerfile - - requirements.txt - - manage.py + - 'Dockerfile' + - 'requirements.txt' + - 'manage.py' jobs: build-and-push: From c336908dbfcee4e0a3573852ce2a0cde352bd128 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 13:53:27 +0300 Subject: [PATCH 16/39] remove paths --- .github/workflows/docker-build.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index dc0abd5..fb33147 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -6,10 +6,6 @@ on: - main types: - closed - paths: - - 'Dockerfile' - - 'requirements.txt' - - 'manage.py' jobs: build-and-push: From a9df789b04d8ef81ffefffa8fadfbfd1bd3cf9d2 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Fri, 6 Jun 2025 14:43:36 +0300 Subject: [PATCH 17/39] 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 @@ # 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 18/39] 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 19/39] 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 20/39] 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 21/39] 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 22/39] 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 23/39] 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 24/39] 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 25/39] 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 26/39] 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 27/39] 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 28/39] 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 29/39] 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 30/39] 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 31/39] 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 32/39] 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 33/39] _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 34/39] 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 35/39] 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 36/39] 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 37/39] 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 38/39] 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 39/39] 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"