-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rakshith B <[email protected]>
- Loading branch information
1 parent
61233e3
commit d55a5fe
Showing
1 changed file
with
59 additions
and
0 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,59 @@ | ||
name: xlsx to csv conversion | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, reopened, synchronize] | ||
workflow_dispatch: | ||
inputs: | ||
message: | ||
description: 'Message for manually triggering' | ||
required: false | ||
default: 'Triggered for Updates' | ||
type: string | ||
|
||
jobs: | ||
convert_xlsx_to_csv: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the repository | ||
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 | ||
run: | | ||
PR_NUMBER=${{ github.event.number }} | ||
commits=$(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/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 | ||
run: | | ||
git config --global user.name "${{ github.event.pull_request.user.login }}" | ||
git config --global user.email "${{ env.author_email }}" | ||
- name: Install xlsx2csv | ||
run: sudo apt-get install -y xlsx2csv | ||
|
||
- name: Create output directory | ||
run: | | ||
rm -rf mosip-data/mosip_master_csv/csv | ||
mkdir -p mosip-data/mosip_master_csv/csv | ||
- name: Convert all XLSX to CSV | ||
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")" | ||
xlsx2csv "$xlsx_file" > "$csv_file" | ||
echo "Converted $xlsx_file to $csv_file" | ||
done | ||
- name: Commit and push changes | ||
run: | | ||
cd mosip-data | ||
git branch | ||
git add . | ||
git commit -s -m "Added converted CSV files" || echo "No changes to commit" | ||
git push "https://x-access-token:${{ secrets.ACTION_PAT }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git" HEAD:${{ github.event.pull_request.head.ref }} |