microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/copyright-headers.yml
56lines · modecode
| 1 | name: Copyright Headers |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | inputs: |
| 6 | soft-fail: |
| 7 | description: 'Whether to continue on copyright header violations' |
| 8 | required: false |
| 9 | type: boolean |
| 10 | default: false |
| 11 | |
| 12 | permissions: |
| 13 | contents: read |
| 14 | |
| 15 | jobs: |
| 16 | copyright-headers: |
| 17 | name: Copyright Header Validation |
| 18 | runs-on: ubuntu-latest |
| 19 | permissions: |
| 20 | contents: read |
| 21 | steps: |
| 22 | - name: Checkout code |
| 23 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2 |
| 24 | with: |
| 25 | persist-credentials: false |
| 26 | fetch-depth: 0 |
| 27 | |
| 28 | - name: Validate copyright headers |
| 29 | id: validate |
| 30 | shell: pwsh |
| 31 | run: | |
| 32 | New-Item -ItemType Directory -Force -Path logs | Out-Null |
| 33 | & scripts/linting/Test-CopyrightHeaders.ps1 -FailOnMissing |
| 34 | if ($LASTEXITCODE -ne 0) { |
| 35 | "COPYRIGHT_FAILED=true" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 36 | } |
| 37 | continue-on-error: ${{ inputs.soft-fail }} |
| 38 | |
| 39 | - name: Upload results |
| 40 | if: always() |
| 41 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4.4.3 |
| 42 | with: |
| 43 | name: copyright-header-results |
| 44 | path: | |
| 45 | logs/copyright-header-results.json |
| 46 | retention-days: 30 |
| 47 | if-no-files-found: ignore |
| 48 | |
| 49 | - name: Check results |
| 50 | if: "!inputs.soft-fail" |
| 51 | shell: pwsh |
| 52 | run: | |
| 53 | if ($env:COPYRIGHT_FAILED -eq 'true') { |
| 54 | Write-Error "Copyright header validation found violations" |
| 55 | exit 1 |
| 56 | } |
| 57 | |