From 55676e564bb6db6077d26e44db45e5748690875d Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:56:31 +0530 Subject: [PATCH 01/10] ED-4000 feat: Github actions instead master using * --- .github/workflows/Build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index f711e051d2c..0d4a135f655 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18.20.2 + node-version: 18 # # Install client dependencies # - name: Install client dependencies From d7465cb9538af6ba8a0a7b9939cc7d87cf7aff83 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:29:18 +0530 Subject: [PATCH 02/10] ED-4000 feat: Github actions instead master using * --- .github/workflows/sonar.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index bdecdb0f4f4..f6f34e0778e 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -3,7 +3,8 @@ name: Sonar on: workflow_run: workflows: [Build-Test] # Trigger when the Build-Test workflow completes - branches: "*" + branches: + - "release-**" types: - completed # Trigger on completion of the Build-Test workflow From a83298e4fed8521dcab473b0c3882b1a7cda59fd Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:14:23 +0530 Subject: [PATCH 03/10] ED-4000 feat: Github actions instead master using --- .github/workflows/Build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 0d4a135f655..f711e051d2c 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 18.20.2 # # Install client dependencies # - name: Install client dependencies From 2442d088bca95b25a43adb6469219768e98ef16d Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:56:51 +0530 Subject: [PATCH 04/10] ED-4000 feat: Github actions instead master using --- .github/workflows/sonar.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index f6f34e0778e..bdecdb0f4f4 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -3,8 +3,7 @@ name: Sonar on: workflow_run: workflows: [Build-Test] # Trigger when the Build-Test workflow completes - branches: - - "release-**" + branches: "*" types: - completed # Trigger on completion of the Build-Test workflow From f2e28fca4d72f5b956e9ce03fc74d74309b30087 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:58:28 +0530 Subject: [PATCH 05/10] ED-4000 feat: Github actions instead master using --- .github/workflows/Build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index f711e051d2c..0d4a135f655 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18.20.2 + node-version: 18 # # Install client dependencies # - name: Install client dependencies From d3e3ec129d6de561ac0a2a337aa136706a7e0878 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:26:08 +0530 Subject: [PATCH 06/10] ED-4000 feat: Github actions instead master using --- .github/workflows/Build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 0d4a135f655..f711e051d2c 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 18.20.2 # # Install client dependencies # - name: Install client dependencies From 32c5e9983feb5534c4821b2b60d0b28ce0ee3ce0 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:26:01 +0530 Subject: [PATCH 07/10] ED-4000 feat: Github actions build job for upload art to azure upload --- .github/workflows/Build.yml | 4 +- .github/workflows/build-upload-artifact.yml | 58 ++++++++++----------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index f711e051d2c..9e97ecbf7e0 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -3,10 +3,10 @@ name: Build-Test on: push: branches: - - "*" # Trigger on push to any branch + - "test" # Trigger on push to any branch pull_request: branches: - - "*" # Trigger on pull request to any branch + - "test" # Trigger on pull request to any branch jobs: ci-cd-TestCases: diff --git a/.github/workflows/build-upload-artifact.yml b/.github/workflows/build-upload-artifact.yml index c31e57fd214..5e386683533 100644 --- a/.github/workflows/build-upload-artifact.yml +++ b/.github/workflows/build-upload-artifact.yml @@ -3,10 +3,10 @@ name: Build and Upload Artifact on: push: branches: - - "deploy" # Trigger on push to the "deploy" branch + - "*" # Trigger on push to the "deploy" branch pull_request: branches: - - "deploy" # Trigger on pull request to the "deploy" branch + - "*" # Trigger on pull request to the "deploy" branch jobs: build_and_deploy: @@ -37,40 +37,38 @@ jobs: commit_hash=$(git rev-parse --short HEAD) # Get commit hash build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} # Generate build tag echo "build_tag=$build_tag" >> $GITHUB_ENV # Save build tag to environment variable - bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" # Run build script with parameters + docker build -t myapp:${build_tag} . # Build Docker image env: NODE_NAME: "18.20.2" # Set environment variable NODE_NAME - # - name: Log in to Docker Hub - # uses: docker/login-action@v2 - # with: - # username: ${{ secrets.DOCKER_USERNAME }} - # password: ${{ secrets.DOCKER_PASSWORD }} - - # - name: Push Docker Image - # run: | - # docker tag my-app:${{ env.build_tag }} ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }} - # docker push ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }} + - name: Save Docker image as a file + run: | + docker save myapp:${{ env.build_tag }} -o myapp_${{ env.build_tag }}.tar # Save Docker image to a file - # - name: Push Docker Image - # uses: docker/build-push-action@v4 - # with: - # context: . - # # file: ./Dockerfile # Path to your Dockerfile - # push: true - # tags: ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }} + - name: Upload to Azure Blob Storage + if: env.AZURE_STORAGE_ACCOUNT + uses: azure/CLI@v1 + with: + inlineScript: | + az storage blob upload \ + --account-name $AZURE_STORAGE_ACCOUNT \ + --container-name my-container \ + --file myapp_${{ env.build_tag }}.tar \ + --name myapp_${{ env.build_tag }}.tar > upload_result.txt + upload_status=$? + if [ $upload_status -ne 0 ]; then + echo "Azure Blob Storage upload failed." + cat upload_result.txt + exit 1 + else + echo "Azure Blob Storage upload succeeded." + fi + env: + AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} + AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} - name: Archive Artifacts uses: actions/upload-artifact@v2 with: name: metadata - path: metadata.json - - - name: Archive CDN assets if required - if: ${{ github.event.inputs.buildCdnAssests == 'true' }} # Conditional step execution - run: | - rm -rf cdn_assets # Remove existing CDN assets directory - mkdir cdn_assets # Create CDN assets directory - cp -r src/app/dist-cdn/* cdn_assets/ # Copy CDN assets - zip -Jr cdn_assets.zip cdn_assets # Create zip file of CDN assets - echo "##vso[task.uploadfile]cdn_assets.zip" # Upload CDN assets zip file + path: myapp_${{ env.build_tag }}.tar From cc83c4fb1e3d839ea9ccd60c0333991a99a6fade Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Mon, 24 Jun 2024 12:25:56 +0530 Subject: [PATCH 08/10] ED-4000 feat: Github actions build job for upload art to azure upload --- .github/workflows/build-upload-artifact.yml | 53 +++++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-upload-artifact.yml b/.github/workflows/build-upload-artifact.yml index 5e386683533..808b0b22f22 100644 --- a/.github/workflows/build-upload-artifact.yml +++ b/.github/workflows/build-upload-artifact.yml @@ -3,10 +3,10 @@ name: Build and Upload Artifact on: push: branches: - - "*" # Trigger on push to the "deploy" branch + - "deploy" # Trigger on push to the "deploy" branch pull_request: branches: - - "*" # Trigger on pull request to the "deploy" branch + - "deploy" # Trigger on pull request to the "deploy" branch jobs: build_and_deploy: @@ -23,7 +23,7 @@ jobs: node-version: "18.20.2" # Set up Node.js version 18 - name: Customize dependencies - if: ${{ env.WL_Customization != null }} # Conditional step execution + if: ${{ github.event.inputs.WL_Customization != '' }} # Conditional step execution run: | git clone --recurse-submodules ${WL_Customization} sunbirded-portal # Clone repository with submodules cp -r sunbirded-portal/images/ src/app/client/src/assets # Copy images to client assets @@ -37,7 +37,7 @@ jobs: commit_hash=$(git rev-parse --short HEAD) # Get commit hash build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} # Generate build tag echo "build_tag=$build_tag" >> $GITHUB_ENV # Save build tag to environment variable - docker build -t myapp:${build_tag} . # Build Docker image + docker build -t myapp:$build_tag . # Build Docker image env: NODE_NAME: "18.20.2" # Set environment variable NODE_NAME @@ -45,24 +45,35 @@ jobs: run: | docker save myapp:${{ env.build_tag }} -o myapp_${{ env.build_tag }}.tar # Save Docker image to a file + - name: Install Azure CLI + run: | + curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash + + - name: Create Azure Blob Storage Container + run: | + az storage container create \ + --name my-container \ + --account-name $AZURE_STORAGE_ACCOUNT \ + --account-key $AZURE_STORAGE_KEY + env: + AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} + AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} + - name: Upload to Azure Blob Storage - if: env.AZURE_STORAGE_ACCOUNT - uses: azure/CLI@v1 - with: - inlineScript: | - az storage blob upload \ - --account-name $AZURE_STORAGE_ACCOUNT \ - --container-name my-container \ - --file myapp_${{ env.build_tag }}.tar \ - --name myapp_${{ env.build_tag }}.tar > upload_result.txt - upload_status=$? - if [ $upload_status -ne 0 ]; then - echo "Azure Blob Storage upload failed." - cat upload_result.txt - exit 1 - else - echo "Azure Blob Storage upload succeeded." - fi + run: | + az storage blob upload \ + --account-name $AZURE_STORAGE_ACCOUNT \ + --container-name my-container \ + --file myapp_${{ env.build_tag }}.tar \ + --name myapp_${{ env.build_tag }}.tar > upload_result.txt + upload_status=$? + if [ $upload_status -ne 0 ]; then + echo "Azure Blob Storage upload failed." + cat upload_result.txt + exit 1 + else + echo "Azure Blob Storage upload succeeded." + fi env: AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} From 91e241419a012693c7eef502eb0dac0a6f26b783 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:38:50 +0530 Subject: [PATCH 09/10] ED-4000 feat: Github actions instead of Jenkins --- .github/workflows/build-upload-artifact.yml | 52 ++++++--------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-upload-artifact.yml b/.github/workflows/build-upload-artifact.yml index 808b0b22f22..744941fa4f4 100644 --- a/.github/workflows/build-upload-artifact.yml +++ b/.github/workflows/build-upload-artifact.yml @@ -23,7 +23,7 @@ jobs: node-version: "18.20.2" # Set up Node.js version 18 - name: Customize dependencies - if: ${{ github.event.inputs.WL_Customization != '' }} # Conditional step execution + if: ${{ env.WL_Customization != null }} # Conditional step execution run: | git clone --recurse-submodules ${WL_Customization} sunbirded-portal # Clone repository with submodules cp -r sunbirded-portal/images/ src/app/client/src/assets # Copy images to client assets @@ -37,46 +37,24 @@ jobs: commit_hash=$(git rev-parse --short HEAD) # Get commit hash build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} # Generate build tag echo "build_tag=$build_tag" >> $GITHUB_ENV # Save build tag to environment variable - docker build -t myapp:$build_tag . # Build Docker image + docker build -t myapp:${build_tag} . # Build Docker image env: NODE_NAME: "18.20.2" # Set environment variable NODE_NAME - - name: Save Docker image as a file - run: | - docker save myapp:${{ env.build_tag }} -o myapp_${{ env.build_tag }}.tar # Save Docker image to a file - - - name: Install Azure CLI - run: | - curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash - - - name: Create Azure Blob Storage Container - run: | - az storage container create \ - --name my-container \ - --account-name $AZURE_STORAGE_ACCOUNT \ - --account-key $AZURE_STORAGE_KEY - env: - AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} - AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} + - name: Docker Login + uses: azure/docker-login@v1 + with: + login-server: ${{ secrets.AZURE_URL }} + username: ${{ secrets.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} - - name: Upload to Azure Blob Storage - run: | - az storage blob upload \ - --account-name $AZURE_STORAGE_ACCOUNT \ - --container-name my-container \ - --file myapp_${{ env.build_tag }}.tar \ - --name myapp_${{ env.build_tag }}.tar > upload_result.txt - upload_status=$? - if [ $upload_status -ne 0 ]; then - echo "Azure Blob Storage upload failed." - cat upload_result.txt - exit 1 - else - echo "Azure Blob Storage upload succeeded." - fi - env: - AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} - AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} + - name: Build and Push to ACR + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.AZURE_URL }}/myapp:${{ env.build_tag }} + file: Dockerfile - name: Archive Artifacts uses: actions/upload-artifact@v2 From 8cc170687c72228adba73a51ed9b7c5bf7aadea2 Mon Sep 17 00:00:00 2001 From: princegupta1131 <114015020+princegupta1131@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:42:45 +0530 Subject: [PATCH 10/10] ED-4000 feat: Github actions instead of Jenkins --- .github/workflows/build-upload-artifact.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-upload-artifact.yml b/.github/workflows/build-upload-artifact.yml index 744941fa4f4..af8d848d8f0 100644 --- a/.github/workflows/build-upload-artifact.yml +++ b/.github/workflows/build-upload-artifact.yml @@ -3,10 +3,10 @@ name: Build and Upload Artifact on: push: branches: - - "deploy" # Trigger on push to the "deploy" branch + - "*" # Trigger on push to the "deploy" branch pull_request: branches: - - "deploy" # Trigger on pull request to the "deploy" branch + - "*" # Trigger on pull request to the "deploy" branch jobs: build_and_deploy: