Skip to content

update pipeline

update pipeline #1

name: Normalize repository files
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
workflow_dispatch:
permissions:
contents: write
concurrency:
group: normalize-repository-${{ github.ref }}
cancel-in-progress: false
jobs:
normalize-repository:
name: Normalize repository files
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Save PowerShell files as UTF-8 with BOM
shell: pwsh
run: |
./.github/scripts/Update-Encoding.ps1 `
-RootPath ./src `
-Recurse `
-BOM `
-Extensions '.ps1', '.psm1', '.psd1'
- name: Save JSON files as UTF-8 without BOM
shell: pwsh
run: |
./.github/scripts/Update-Encoding.ps1 `
-RootPath ./src `
-Recurse `
-Extensions '.json'
- name: Normalize JSON indentation and syntax
shell: pwsh
run: |
./.github/scripts/Format-JsonFiles.ps1 `
-RootPath ./src/monkey365/rules `
-Recurse `
-CamelCase
- name: Publish normalized files
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
shell: pwsh
run: |
git add -- src
git diff --cached --quiet
$diffExitCode = $LASTEXITCODE
if ($diffExitCode -eq 0) {
Write-Host 'No normalized files changed; nothing to commit.'
exit 0
}
if ($diffExitCode -ne 1) {
throw "Unable to inspect normalized files (git exit code $diffExitCode)."
}
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -m 'chore: normalize repository files [skip ci]'
if ($LASTEXITCODE -ne 0) {
throw "Unable to commit normalized files (git exit code $LASTEXITCODE)."
}
git push origin "HEAD:$env:GITHUB_REF_NAME"
if ($LASTEXITCODE -ne 0) {
throw "Unable to push normalized files (git exit code $LASTEXITCODE)."
}