From d75740b6a4149b3098cc90fdf4b274a1334c1009 Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Tue, 14 Apr 2026 13:29:36 +0000 Subject: [PATCH 1/4] testing (#16) Co-authored-by: Priyanshu Vishwakarma Reviewed-on: http://git.wdipl.com/KLC/KLC-Hr-Dashboard-Frontend/pulls/16 --- .gitea/workflows/build.yml | 34 +++++++++++++ .gitea/workflows/compressimage.yml | 67 ++++++++++++++++++++++++++ .gitea/workflows/deploy.yml | 77 ++++++++++++++++++++++++++++++ .gitea/workflows/sonar.yml | 39 +++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/compressimage.yml create mode 100644 .gitea/workflows/deploy.yml create mode 100644 .gitea/workflows/sonar.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..169ee1d --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,34 @@ +name: Klc-HR-Dashboard-Frontend-Build-Check + +on: + pull_request: + branches: + - main + - beta + - testing + - client + - staging + - production + +jobs: + build-test: + name: Build and Test PR + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Dependencies + run: npm install + + - name: Build Check + run: npm run build + + - name: Audit Dependencies + run: npm audit --audit-level=critical \ No newline at end of file diff --git a/.gitea/workflows/compressimage.yml b/.gitea/workflows/compressimage.yml new file mode 100644 index 0000000..f927196 --- /dev/null +++ b/.gitea/workflows/compressimage.yml @@ -0,0 +1,67 @@ +name: Enforce Image Standards + +on: + pull_request: + branches: + - main + - beta + - testing + - client + - staging + - production + types: [opened, synchronize, reopened] + paths: + - '**/*.jpg' + - '**/*.jpeg' + - '**/*.png' + workflow_dispatch: + +jobs: + optimize: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ gitea.head_ref }} # IMPORTANT + + - name: Install Image Tools + run: | + sudo apt-get update + sudo apt-get install -y imagemagick jpegoptim pngquant + + - name: Resize Oversized Images + run: | + find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \ + -exec mogrify -resize 1920x1920\> {} \; + + - name: Optimize JPEG + run: | + find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) \ + -exec jpegoptim --strip-all --max=85 {} \; + + - name: Optimize PNG + run: | + find . -type f -iname "*.png" \ + -exec pngquant --force --ext .png --quality=75-90 {} \; + + # Commit changes if any + - name: Commit changes + run: | + git config --global user.name "CI Bot" + git config --global user.email "ci@local" + + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "chore: optimize images via CI" + else + echo "No changes to commit" + fi + + # Push back to PR branch + - name: Push changes + if: success() + run: | + git push origin HEAD:${{ gitea.head_ref }} \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..6d9d622 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,77 @@ +name: Klc-Learner-Frontend-CD + +on: + push: + branches: + - beta + - testing + - client + - staging + - production + +jobs: + deploy: + name: Deploying code in Server + runs-on: ubuntu-latest + + steps: + - name: Checkout Code in Runner + uses: actions/checkout@v3 + + - name: Determine Project Folder + run: | + echo "Detected Branch Name : ${{ gitea.ref_name }}" + BRANCH_NAME=${{ gitea.ref_name }} + + case "$BRANCH_NAME" in + beta) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + testing) + echo "PROJECT_FOLDER=/home/klc/klc-frontend/Test_Release/KLC-Hr-Dashboard-Frontend" >> $GITHUB_ENV + ;; + client) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + staging) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + production) + echo "PROJECT_FOLDER=null" >> $GITHUB_ENV + ;; + *) + echo "UNKNOWN BRANCH" + exit 1 + ;; + esac + + echo "BRANCH_NAME=${{ gitea.ref_name }}" >> $GITHUB_ENV + + - name: Deploy Using SSH + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.BETA_SERVER_HOST }} + username: ${{ secrets.BETA_SERVER_USERNAME }} + password: ${{ secrets.BETA_SERVER_PASSWORD }} + port: ${{ secrets.BETA_SERVER_PORT }} + envs: BRANCH_NAME,PROJECT_FOLDER + script: | + set -e + + if [ "$PROJECT_FOLDER" = "null" ]; then + echo "No deployment configured for this branch" + exit 0 + fi + + cd $PROJECT_FOLDER + + git fetch + git reset --hard origin/$BRANCH_NAME + git stash && git stash clear || true + git pull origin $BRANCH_NAME + + echo "Installing Node Modules..." + npm install + + echo "Building..." + npm run build \ No newline at end of file diff --git a/.gitea/workflows/sonar.yml b/.gitea/workflows/sonar.yml new file mode 100644 index 0000000..d64b636 --- /dev/null +++ b/.gitea/workflows/sonar.yml @@ -0,0 +1,39 @@ +name: Klc-Learner-Frontend-Sonar + +on: + pull_request: + branches: + - main + - beta + - testing + - client + - staging + - production + +jobs: + sonarqube: + name: SonarQube Scan + runs-on: ubuntu-latest + + container: + image: sonarsource/sonar-scanner-cli:12.0.0.3214_8.0.1 + options: --user root + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run Sonar Scan + run: | + REPO_NAME=${{ gitea.event.repository.name }} + + sonar-scanner \ + -Dsonar.projectKey=$REPO_NAME \ + -Dsonar.projectName=$REPO_NAME \ + -Dsonar.sources=. \ + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} \ + -Dsonar.token=${{ secrets.SONARQUBE_TOKEN }} \ + -Dsonar.exclusions=node_modules/**,dist/**,coverage/** \ + -Dsonar.qualitygate.wait=true \ No newline at end of file From d96c7ea4241b709a0c762075d3d6e364f538e7ef Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Tue, 14 Apr 2026 13:52:05 +0000 Subject: [PATCH 2/4] Update .gitea/workflows/sonar.yml --- .gitea/workflows/sonar.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/sonar.yml b/.gitea/workflows/sonar.yml index d64b636..a811a78 100644 --- a/.gitea/workflows/sonar.yml +++ b/.gitea/workflows/sonar.yml @@ -1,4 +1,4 @@ -name: Klc-Learner-Frontend-Sonar +name: Sonar Check on: pull_request: From a4b8de32debfb2aa329dab81a9f7fea9ae6f9fe1 Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Tue, 14 Apr 2026 13:56:10 +0000 Subject: [PATCH 3/4] Update .gitea/workflows/deploy.yml --- .gitea/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 6d9d622..62cf9f4 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Klc-Learner-Frontend-CD +name: Deploy on: push: From 0c564e5a9446c6255d9ccfef28e607c25958ad75 Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Tue, 14 Apr 2026 13:57:26 +0000 Subject: [PATCH 4/4] Update .gitea/workflows/build.yml --- .gitea/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 169ee1d..8b795ab 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,4 +1,4 @@ -name: Klc-HR-Dashboard-Frontend-Build-Check +name: Build-Check on: pull_request: