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..26d39f4a --- /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 80: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://16.170.173.25:80', 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 80: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/README.md b/README.md index 9567a17d..e712bacf 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,4 @@ -![Watch Now](./img/Design.jpg) -# One page Portfolio Website (HTML CSS Project) -**Watch on YouTube ![YouTube Video Views](https://img.shields.io/youtube/views/ZFQkb26UD1Y?style=social) : https://youtu.be/ZFQkb26UD1Y** ---- - -### Made with ❤️ by [Shaif Arfan](https://www.instagram.com/shaifarfan08/) - -Like my works and want to support me? - -Buy Me A Coffee - ---- - -## Other projects - -📚 [All Web Cifar Project Tutorials](https://github.com/ShaifArfan/wc-project-tutorials) diff --git a/debug.log b/debug.log new file mode 100644 index 00000000..13bf6336 --- /dev/null +++ b/debug.log @@ -0,0 +1,2 @@ +[1226/130637.454:ERROR:registration_protocol_win.cc(107)] CreateFile: The system cannot find the file specified. (0x2) +[1226/130637.986:ERROR:registration_protocol_win.cc(107)] CreateFile: The system cannot find the file specified. (0x2) diff --git a/index.html b/index.html index 1a429961..206f88a8 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,11 @@