16
.github/workflows/jenkins-deploy.yml
vendored
Normal file
16
.github/workflows/jenkins-deploy.yml
vendored
Normal file
@@ -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"
|
||||
36
Jenkinsfile
vendored
Normal file
36
Jenkinsfile
vendored
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,4 @@ Application made by django's instruction for **DevOps** education purposes
|
||||
|
||||
# Pylint
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user