diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..bbdaea2
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,58 @@
+name: NetflixFrontend Build
+
+on:
+ push:
+ branches:
+ - main
+
+permissions:
+ contents: write
+ pull-requests: write
+ actions: read
+
+jobs:
+ Build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout the repo code
+ uses: actions/checkout@v3
+
+ - name: Build and push image
+ env:
+ DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
+ DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
+ run: |
+ if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ]; then
+ echo "Your DockerHub username and password should be set as secrets!!"
+ exit 1
+ fi
+
+ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
+
+ IMAGE_NAME=$DOCKER_USERNAME/netflix-frontend:${{ github.run_number }}
+ docker build -t $IMAGE_NAME .
+ docker push $IMAGE_NAME
+
+ - name: Checkout infrastructure repo
+ uses: actions/checkout@v3
+ with:
+ repository: lidorbashari/NetflixInfra
+ token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+ path: ./NetflixInfra
+ ref: main
+
+ - name: Update YAML manifests
+ run: |
+ IMAGE_NAME=${{ secrets.DOCKERHUB_USERNAME }}/netflix-frontend:${{ github.run_number }}
+ cd ./NetflixInfra/k8s/NetflixFrontend
+ yq e ".spec.template.spec.containers[0].image = \"$IMAGE_NAME\"" -i ./deployment.yaml
+
+
+ - name: Commit and Push changes
+ run: |
+ cd ./NetflixInfra
+ git config --local user.email "github@action"
+ git config --local user.name "auto-update"
+ git add k8s/NetflixFrontend/deployment.yaml
+ git commit -m "Update image to $IMAGE_NAME"
+ git push origin main
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/NetflixFrontend.iml b/.idea/NetflixFrontend.iml
new file mode 100644
index 0000000..f571432
--- /dev/null
+++ b/.idea/NetflixFrontend.iml
@@ -0,0 +1,8 @@
+
+
Made by{' '} - Ayushi Gupta + Ayushi Gupta!!!!! and lidor
diff --git a/pipelines/build-dev.Jenkinsfile b/pipelines/build-dev.Jenkinsfile new file mode 100644 index 0000000..86e8ce1 --- /dev/null +++ b/pipelines/build-dev.Jenkinsfile @@ -0,0 +1,54 @@ +pipeline { + agent { + label 'general' + } + + triggers { + githubPush() // trigger the pipeline upon push event in github + } + + options { + timeout(time: 10, unit: 'MINUTES') // discard the build after 10 minutes of running + timestamps() // display timestamp in console outputs + } + + environment { + // GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + // TIMESTAMP = new Date().format("yyyyMMdd-HHmmss") + + IMAGE_TAG = "v1.0.$BUILD_NUMBER" + IMAGE_BASE_NAME = "netflix-frontend-dev" + + DOCKER_CREDS = credentials('dockerhub') + DOCKER_USERNAME = "${DOCKER_CREDS_USR}" // The _USR suffix added to access the username value + DOCKER_PASS = "${DOCKER_CREDS_PSW}" // The _PSW suffix added to access the password value + } + + stages { + stage('Docker setup') { + steps { + sh ''' + docker login -u $DOCKER_USERNAME -p $DOCKER_PASS + ''' + } + } + + stage('Build & Push') { + steps { + sh ''' + IMAGE_FULL_NAME=$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG + docker build --push -t $IMAGE_FULL_NAME . + + ''' + } + } + stage('Trigger Deploy') { + steps { + build job: 'frontend-deploy-dev', wait: false, parameters: [ + string(name: 'SERVICE_NAME', value: "NetflixFrontendDev"), + string(name: 'IMAGE_FULL_NAME_PARAM', value: "$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG") + ] + } + } + } +} \ No newline at end of file diff --git a/pipelines/build.Jenkinsfile b/pipelines/build.Jenkinsfile new file mode 100644 index 0000000..de0f309 --- /dev/null +++ b/pipelines/build.Jenkinsfile @@ -0,0 +1,54 @@ +pipeline { + agent { + label 'general' + } + + triggers { + githubPush() // trigger the pipeline upon push event in github + } + + options { + timeout(time: 10, unit: 'MINUTES') // discard the build after 10 minutes of running + timestamps() // display timestamp in console outputs + } + + environment { + // GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + // TIMESTAMP = new Date().format("yyyyMMdd-HHmmss") + + IMAGE_TAG = "v1.0.$BUILD_NUMBER" + IMAGE_BASE_NAME = "netflix-frontend" + + DOCKER_CREDS = credentials('dockerhub') + DOCKER_USERNAME = "${DOCKER_CREDS_USR}" // The _USR suffix added to access the username value + DOCKER_PASS = "${DOCKER_CREDS_PSW}" // The _PSW suffix added to access the password value + } + + stages { + stage('Docker setup') { + steps { + sh ''' + docker login -u $DOCKER_USERNAME -p $DOCKER_PASS + ''' + } + } + + stage('Build & Push') { + steps { + sh ''' + IMAGE_FULL_NAME=$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG + docker build --push -t $IMAGE_FULL_NAME . + + ''' + } + } + stage('Trigger Deploy') { + steps { + build job: 'frontend-deploy', wait: false, parameters: [ + string(name: 'SERVICE_NAME', value: "NetflixFrontend"), + string(name: 'IMAGE_FULL_NAME_PARAM', value: "$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG") + ] + } + } + } +} \ No newline at end of file diff --git a/pipelines/test.Jenkinsfile b/pipelines/test.Jenkinsfile new file mode 100644 index 0000000..94a57e0 --- /dev/null +++ b/pipelines/test.Jenkinsfile @@ -0,0 +1,46 @@ +pipeline { + agent { + label 'general' + } + + stages { + stage('Tests before build') { + parallel { + stage('Unittest') { + steps { + sh 'echo unittesting...' + } + } + stage('Lint') { + steps { + sh 'echo linting...' + } + } + } + } + stage('Build and deploy to Test environment') { + steps { + sh 'echo trigger build and deploy pipelines for test environment... wait until successful deployment' + } + } + stage('Tests after build') { + parallel { + stage('Security vulnerabilities scanning') { + steps { + sh 'echo scanning for vulnerabilities...' + } + } + stage('API test') { + steps { + sh 'echo testing API...' + } + } + stage('Load test') { + steps { + sh 'echo testing under load...' + } + } + } + } + } +} \ No newline at end of file