Skip to content

Commit

Permalink
ED-4000 feat: Github actions instead of Jenkins-test-sonar-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
princegupta1131 committed Jun 12, 2024
1 parent 44a4603 commit 4b021cd
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 17 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-upload-artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Upload Artifact

on:
push:
branches:
- "deploy" # Trigger on push to any branch
pull_request:
branches:
- "deploy" # Trigger on pull request to any branch

jobs:
build_and_deploy:
name: Build and Upload Artifact Job # Define the name of the job
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2 # Checkout the repository code

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18.20.2" # Set up Node.js version 18

- name: Customize dependencies
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
cp -r sunbirded-portal/resourceBundles/data/ src/app/resourcebundles/ # Copy resource bundle data
env:
WL_Customization: ${{ github.event.inputs.WL_Customization }} # Set environment variable WL_Customization

- name: Build and Create Docker Image
run: |
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" # Print build tag
bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" # Run build script with parameters
env:
NODE_NAME: "18.20.2" # Set environment variable NODE_NAME

- 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
31 changes: 31 additions & 0 deletions .github/workflows/cd-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Use the data

on:
workflow_run:
workflows: [Upload data]
types:
- completed

jobs:
download:
runs-on: ubuntu-latest
steps:
- name: Print SONAR_TOKEN
run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123"

# Install Sonar Scanner
- name: Install Sonar Scanner
run: |
cd /tmp
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
sudo apt-get install -y unzip
unzip sonar-scanner-cli-5.0.1.3006-linux.zip
cd -
# Run SonarScanner for frontend (Angular)
- name: Run SonarScanner for frontend
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
/tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \
-Dsonar.login=$SONAR_TOKEN
34 changes: 17 additions & 17 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,25 @@ jobs:
# yarn install
# npm run test:ci
# Debug: Print the masked SONAR_TOKEN
- name: Print SONAR_TOKEN
run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123"
# - name: Print SONAR_TOKEN
# run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123"

#Install Sonar Scanner
- name: Install Sonar Scanner
run: |
cd /tmp
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
sudo apt-get install -y unzip
unzip sonar-scanner-cli-5.0.1.3006-linux.zip
cd -
# #Install Sonar Scanner
# - name: Install Sonar Scanner
# run: |
# cd /tmp
# wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
# sudo apt-get install -y unzip
# unzip sonar-scanner-cli-5.0.1.3006-linux.zip
# cd -

# Run SonarScanner for frontend (Angular)
- name: Run SonarScanner for frontend
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
/tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \
-Dsonar.login=$SONAR_TOKEN
# # Run SonarScanner for frontend (Angular)
# - name: Run SonarScanner for frontend
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: |
# /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \
# -Dsonar.login=$SONAR_TOKEN

# - name: Run Sonar Scanner
# env:
Expand Down

0 comments on commit 4b021cd

Please sign in to comment.