-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ED-4000 feat: Github actions instead of Jenkins-test-sonar-fix
- Loading branch information
1 parent
44a4603
commit 4b021cd
Showing
3 changed files
with
104 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters