From 2ba10a79e57e40529fbb504573d835722e8814eb Mon Sep 17 00:00:00 2001 From: Natsu Tadama Date: Sun, 28 Jul 2024 03:10:48 +0700 Subject: [PATCH] Refactor action script, use bash instead --- .github/workflows/they_said_to_compile.yaml | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/they_said_to_compile.yaml b/.github/workflows/they_said_to_compile.yaml index 8d0ac85..d67131f 100644 --- a/.github/workflows/they_said_to_compile.yaml +++ b/.github/workflows/they_said_to_compile.yaml @@ -11,25 +11,29 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Configure Git + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - name: Run Groovy Compiler - shell: pwsh run: | # Find groovy files starts with _ on current directory - $groovyFiles = Get-ChildItem -Path . -Filter "_*.groovy" -Recurse + groovyFiles=$(find . -type f -name "_*.groovy") + # Compile each groovy file - foreach ($file in $groovyFiles) { - $compiledFile = "compiled/$($file.Name -replace '^_','')" - Write-Host "Compiling $($file.FullName) to $compiledFile" - python3 compiler.py $file.FullName $compiledFile - } + for file in $groovyFiles; do + compiledFile="compiled/$(basename "$file" | sed 's/^_//')" + echo "Compiling $file to $compiledFile" + python3 compiler.py "$file" "$compiledFile" + done - name: Commit and Push Changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" git add compiled git commit -m "Compile Groovy Scripts" git push