From 9ab9dc637fbe4d796637ed7b81d044c9e8190dae Mon Sep 17 00:00:00 2001 From: Joel Wembo Date: Wed, 24 Apr 2024 02:19:06 +0800 Subject: [PATCH] added workflows --- .github/workflows/SonarQube-workflow.yaml | 29 ++++++++++++++ deployments/Jenkins/Jenkinsfile | 10 ++--- deployments/Jenkins/JenkinsfileTemplate | 7 +--- .../terraform/installer.sh | 40 +++++++++---------- 4 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/SonarQube-workflow.yaml diff --git a/.github/workflows/SonarQube-workflow.yaml b/.github/workflows/SonarQube-workflow.yaml new file mode 100644 index 0000000..60f3a91 --- /dev/null +++ b/.github/workflows/SonarQube-workflow.yaml @@ -0,0 +1,29 @@ +name: "sonar_cloud_scan_github_actions" + +on: + push: + branches: ['master' , 'main'] + pull_request: + branches: ['master', 'main'] + +permissions: + contents: write + + +jobs: + DemoSonarCloudSCan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.organization=rekhugopal + -Dsonar.projectKey=SonarCloudCodeAnalyisis + -Dsonar.python.coverage.reportPaths=coverage.xml \ No newline at end of file diff --git a/deployments/Jenkins/Jenkinsfile b/deployments/Jenkins/Jenkinsfile index a37ae87..ff73105 100644 --- a/deployments/Jenkins/Jenkinsfile +++ b/deployments/Jenkins/Jenkinsfile @@ -9,11 +9,11 @@ pipeline{ registry = "" registryCredential = "" projectPath = "" - AWS_ACCESS_KEY_ID = credentials('your_aws_access_key_id') - AWS_SECRET_ACCESS_KEY = credentials('your_aws_secret_access_key') - AWS_REGION = 'your_aws_region' - EC2_INSTANCE = 'your_ec2_instance_id' - SSH_KEY = credentials('your_ssh_key') + AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID') + AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY') + AWS_REGION = credentials('AWS_REGION') + EC2_INSTANCE = credentials('EC2_INSTANCE') + AWS_SSH_KEY = credentials('AWS_SSH_KEY') } stages { diff --git a/deployments/Jenkins/JenkinsfileTemplate b/deployments/Jenkins/JenkinsfileTemplate index dd3a3b7..6013f2c 100644 --- a/deployments/Jenkins/JenkinsfileTemplate +++ b/deployments/Jenkins/JenkinsfileTemplate @@ -71,13 +71,8 @@ pipeline{ sh 'docker-compose up -d' } } - stage('Execute Manuel Tests'){ - steps { - sh 'echo "Migration Operation Completed , Please Check the logs status"' - } - } - stage('Deploy to AWS') { + stage('Deploy to AWS EC2') { steps { dir('deployments') { sh "pwd" diff --git a/deployments/terraform/terraform-aws-ec2-tf/terraform/installer.sh b/deployments/terraform/terraform-aws-ec2-tf/terraform/installer.sh index db2b537..cf88004 100644 --- a/deployments/terraform/terraform-aws-ec2-tf/terraform/installer.sh +++ b/deployments/terraform/terraform-aws-ec2-tf/terraform/installer.sh @@ -1,27 +1,27 @@ #!/bin/bash -# Java Installations -# sudo apt-get install openjdk-11-jdk -y -# sudo apt-get install zip -y -# echo 'JDK Installed successfully installer' +Java Installations +sudo apt-get install openjdk-11-jdk -y +sudo apt-get install zip -y +echo 'JDK Installed successfully installer' -# # Jenkins installations -# sudo apt update -# apt install make -# sudo apt-get install debian-keyring debian-archive-keyring --assume-yes -# sudo apt-key update -# sudo apt-get update -# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 -# sudo apt update -# sudo apt install openjdk-11-jre-headless --assume-yes -# sudo java -version -# curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null -# echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null -# sudo apt-get update -# sudo apt-get install jenkins --assume-yes -# # sudo service jenkins status -# echo 'Jenkins successfully installer : password ' +# Jenkins installations +sudo apt update +apt install make +sudo apt-get install debian-keyring debian-archive-keyring --assume-yes +sudo apt-key update +sudo apt-get update +sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 +sudo apt update +sudo apt install openjdk-11-jre-headless --assume-yes +sudo java -version +curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null +echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null +sudo apt-get update +sudo apt-get install jenkins --assume-yes +# sudo service jenkins status +echo 'Jenkins successfully installer' # # Postgres Installation # sudo apt update # # enable repository to install postgresql