From 863d68c508b8da15ecc4079efc3001d3f2f30ec9 Mon Sep 17 00:00:00 2001 From: Abhishek S <127825992+abhishek8shankar@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:49:15 +0530 Subject: [PATCH] [MOSIP-44260] Update xlsx-to-csv.yml Signed-off-by: Abhishek S <127825992+abhishek8shankar@users.noreply.github.com> --- .github/workflows/xlsx-to-csv.yml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/xlsx-to-csv.yml b/.github/workflows/xlsx-to-csv.yml index fd26b001..f3f2aaeb 100644 --- a/.github/workflows/xlsx-to-csv.yml +++ b/.github/workflows/xlsx-to-csv.yml @@ -1,5 +1,4 @@ name: xlsx to csv conversion - on: pull_request_target: types: [opened, reopened, synchronize] @@ -15,12 +14,29 @@ jobs: convert_xlsx_to_csv: runs-on: ubuntu-latest steps: + - name: Check for xlsx changes + id: check_xlsx + run: | + PR_NUMBER=${{ github.event.number }} + FILES=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/files") + XLSX_CHANGED=$(echo "$FILES" | jq '[.[].filename | select(endswith(".xlsx"))] | length') + echo "xlsx_changed=$XLSX_CHANGED" >> $GITHUB_OUTPUT + + - name: Skip if no xlsx changes + if: steps.check_xlsx.outputs.xlsx_changed == '0' && github.event_name != 'workflow_dispatch' + run: | + echo "No xlsx files changed. Skipping workflow." + exit 0 + - name: Clone the repository + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: | - #git clone -b ${{ github.event.pull_request.head.ref }} "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git" git clone -b ${{ github.event.pull_request.head.ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git - - - name: Get author email + + - name: Get author email + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: | PR_NUMBER=${{ github.event.number }} commits=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ @@ -28,21 +44,25 @@ jobs: "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/commits") email=$(echo "$commits" | jq -r '.[0].commit.author.email // "${{ github.event.pull_request.user.login }}@users.noreply.github.com"') echo "author_email=$email" >> $GITHUB_ENV - + - name: Set up Git identity + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: | git config --global user.name "${{ github.event.pull_request.user.login }}" git config --global user.email "${{ env.author_email }}" - name: Install xlsx2csv + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: sudo apt-get install -y xlsx2csv - name: Create output directory + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: | rm -rf mosip-data/mosip_master_csv/csv mkdir -p mosip-data/mosip_master_csv/csv - name: Convert all XLSX to CSV + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: | for xlsx_file in mosip-data/mosip_master/xlsx/*.xlsx; do csv_file="mosip-data/mosip_master_csv/csv/$(basename "${xlsx_file%.xlsx}.csv")" @@ -51,6 +71,7 @@ jobs: done - name: Commit and push changes + if: steps.check_xlsx.outputs.xlsx_changed != '0' || github.event_name == 'workflow_dispatch' run: | cd mosip-data git branch