From cbe0f4b1fa2b2021bbeb92f803b6e5faa97fbf97 Mon Sep 17 00:00:00 2001 From: fukusuket <41001169+fukusuket@users.noreply.github.com> Date: Sun, 9 Mar 2025 15:53:19 +0900 Subject: [PATCH] add csv --- .github/workflows/create-csv.yml | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/create-csv.yml diff --git a/.github/workflows/create-csv.yml b/.github/workflows/create-csv.yml new file mode 100644 index 00000000..d40a4801 --- /dev/null +++ b/.github/workflows/create-csv.yml @@ -0,0 +1,55 @@ +name: Create auditpol_output.csv + +on: + push: + branches: [ "main" ] + workflow_dispatch: + +jobs: + build: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v4 + + - name: Generate csv from auditpol /list /subcategory:* /r + run: | + $data = auditpol /list /subcategory:* /r + $output = @() + $category = "" + foreach ($line in $data) { + if ($line -match "^Category/Subcategory") { continue } + if ($line -match "^\s+(.+),\{(.+)\}$") { + $subcategory = $matches[1].Trim() + $guid = $matches[2].Trim() + $output += [PSCustomObject]@{ + Category = $category + Subcategory = $subcategory + GUID = $guid + } + } elseif ($line -match "^(.+),\{(.+)\}$") { + $category = $matches[1].Trim() + $guid = $matches[2].Trim() + $output += [PSCustomObject]@{ + Category = $category + Subcategory = "" + GUID = $guid + } + } + } + $output | Export-Csv -Path "config/eid_subcategory_mapping.csv" -NoTypeInformation -Encoding UTF8 + $output | Format-Table -AutoSize + + - name: Configure Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Commit changes + run: | + git add *.csv + if (git diff-index --quiet HEAD) { + echo "No changes to commit" + } else { + git commit -m "Automated update" + git push origin main + }