From 6d945ed8fb26abac67971aa7fbd8f37e3c9d31f6 Mon Sep 17 00:00:00 2001
From: Taimoor Khan <82448357+taimooorr@users.noreply.github.com>
Date: Sun, 24 Dec 2023 10:27:05 +0500
Subject: [PATCH 01/17] updated
---
README.md | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/README.md b/README.md
index 9567a17d..e712bacf 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,4 @@
-
-# One page Portfolio Website (HTML CSS Project)
-**Watch on YouTube  : https://youtu.be/ZFQkb26UD1Y**
----
-
-### Made with ❤️ by [Shaif Arfan](https://www.instagram.com/shaifarfan08/)
-
-Like my works and want to support me?
-
-
-
----
-
-## Other projects
-
-📚 [All Web Cifar Project Tutorials](https://github.com/ShaifArfan/wc-project-tutorials)
From a4dabb2b0aed4e2b12ced5ed046284ea0b13d9f9 Mon Sep 17 00:00:00 2001
From: Taimoor Khan <82448357+taimooorr@users.noreply.github.com>
Date: Sun, 24 Dec 2023 10:36:06 +0500
Subject: [PATCH 02/17] added pipeline
---
Dockerfile | 3 ++
Jenkinsfile | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++
index.html | 4 +--
3 files changed, 92 insertions(+), 2 deletions(-)
create mode 100644 Dockerfile
create mode 100644 Jenkinsfile
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..ddbae980
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,3 @@
+FROM nginx:alpine
+COPY . /usr/share/nginx/html
+EXPOSE 80
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 00000000..d471d23d
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,87 @@
+pipeline {
+ agent any
+
+ stages {
+ stage('Build') {
+ steps {
+ script {
+ dockerImage = docker.build("amuavia/personal-portfolio:${env.BUILD_ID}")
+ }
+ }
+ }
+ stage('Push') {
+ steps {
+ script {
+ docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
+ dockerImage.push()
+ }
+ }
+ }
+ }
+
+ stage('Test') {
+ steps {
+ sh 'ls -l index.html' // Simple check for index.html
+ }
+ }
+
+ stage('Deploy') {
+ steps {
+ script {
+ // Deploy the new version
+ sshPublisher(
+ publishers: [
+ sshPublisherDesc(
+ configName: "MyUbuntuServer",
+ transfers: [sshTransfer(
+ execCommand: """
+ docker pull amuavia/personal-portfolio:${env.BUILD_ID}
+ docker stop personal-portfolio-container || true
+ docker rm personal-portfolio-container || true
+ docker run -d --name personal-portfolio-container -p 400:80 amuavia/personal-portfolio:${env.BUILD_ID}
+ """
+ )]
+ )
+ ]
+ )
+
+ // Check if deployment is successful
+ boolean isDeploymentSuccessful = sh(script: 'curl -s -o /dev/null -w "%{http_code}" http://51.20.126.236:400', returnStdout: true).trim() == '200'
+
+ if (!isDeploymentSuccessful) {
+ // Rollback to the previous version
+ def previousSuccessfulTag = readFile('previous_successful_tag.txt').trim()
+ sshPublisher(
+ publishers: [
+ sshPublisherDesc(
+ configName: "MyUbuntuServer",
+ transfers: [sshTransfer(
+ execCommand: """
+ docker pull amuavia/personal-portfolio:${previousSuccessfulTag}
+ docker stop personal-portfolio-container || true
+ docker rm personal-portfolio-container || true
+ docker run -d --name personal-portfolio-container -p 400:80 amuavia/personal-portfolio:${previousSuccessfulTag}
+ """
+ )]
+ )
+ ]
+ )
+ } else {
+ // Update the last successful tag
+ writeFile file: 'previous_successful_tag.txt', text: "${env.BUILD_ID}"
+ }
+ }
+ }
+ }
+ }
+
+ post {
+ failure {
+ mail(
+ to: 'muaviaa099@gmail.com',
+ subject: "Failed Pipeline: ${env.JOB_NAME} [${env.BUILD_NUMBER}]",
+ body: "Something is wrong with the build ${env.BUILD_URL}"
+ )
+ }
+ }
+}
diff --git a/index.html b/index.html
index 1a429961..96b9ce92 100644
--- a/index.html
+++ b/index.html
@@ -15,7 +15,7 @@
-