|
| 1 | +name: Powershell Compiler |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + paths: [ "src/**/*.ps1", ".github/workflows/compile-scripts.yaml" ] |
| 7 | + pull_request: |
| 8 | + paths: [ "src/**/*.ps1", ".github/workflows/compile-scripts.yaml" ] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + changes: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + compiled: ${{ steps.changes.outputs.compiled }} |
| 16 | + src: ${{ steps.changes.outputs.src }} |
| 17 | + src_deleted: ${{ steps.changes.outputs.src_deleted }} |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + # Checks for changes in the 'compiled' and 'src' directories |
| 23 | + # We also check for deleted files so we can cleanup the compiled directory |
| 24 | + - name: Collect Changes for Upcoming Jobs |
| 25 | + uses: dorny/paths-filter@v3.0.2 |
| 26 | + id: changes |
| 27 | + with: |
| 28 | + list-files: shell |
| 29 | + filters: | |
| 30 | + compiled: |
| 31 | + - 'compiled/**' |
| 32 | + src: |
| 33 | + - 'src/**/*.(ps1|psm1)' |
| 34 | + src_deleted: |
| 35 | + - deleted: 'src/**/*.(ps1|psm1)' |
| 36 | +
|
| 37 | + cleanup-directory: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: changes |
| 40 | + if: needs.changes.outputs.src_deleted == 'true' |
| 41 | + permissions: |
| 42 | + contents: write |
| 43 | + steps: |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Delete Compiled versions of deleted files |
| 48 | + id: delete_files |
| 49 | + run: ./utils/clean-compiled.sh |
| 50 | + |
| 51 | + - name: Commit Changes |
| 52 | + if: ${{ steps.delete_files.outputs.FOUND_DELETED == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }} |
| 53 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 54 | + with: |
| 55 | + commit_message: "chore(compiled): Remove compiled versions of deleted files" |
| 56 | + |
| 57 | + build: |
| 58 | + uses: ./.github/workflows/build.yaml |
| 59 | + |
| 60 | + compile-scripts: |
| 61 | + runs-on: windows-latest |
| 62 | + needs: [changes, build] |
| 63 | + if: ${{ needs.changes.outputs.src == 'true' }} |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Download Compiler Artifact |
| 72 | + uses: dawidd6/action-download-artifact@v6 |
| 73 | + with: |
| 74 | + workflow: build.yaml |
| 75 | + workflow_conclusion: success |
| 76 | + name: Compiler |
| 77 | + path: /tmp/Compiler |
| 78 | + |
| 79 | + - name: Run Compiler |
| 80 | + shell: pwsh |
| 81 | + run: /tmp/Compiler/Compiler.exe --input src --output compiled --force -vvv -f |
| 82 | + |
| 83 | + - name: Commit Changes |
| 84 | + if: ${{ github.event_name == 'workflow_dispatch' || (needs.changes.outputs.src == 'true' && github.event_name == 'push') }} |
| 85 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 86 | + with: |
| 87 | + commit_message: "chore(compiled): Compile scripts" |
0 commit comments