|
| 1 | +--- |
| 2 | + |
| 3 | +on: # yamllint disable-line rule:truthy |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + repository: |
| 7 | + description: 'The repository that needs linting' |
| 8 | + type: string |
| 9 | + default: ${{ github.repository }} |
| 10 | + required: false |
| 11 | + ref: |
| 12 | + description: 'The branch, tag or SHA that needs linting' |
| 13 | + type: string |
| 14 | + required: false |
| 15 | + default: ${{ github.ref }} |
| 16 | + config_file: |
| 17 | + description: 'The location of the linter-configuration' |
| 18 | + type: string |
| 19 | + required: false |
| 20 | + default: 'tools/linters/xmllint.json' |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + linter: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + #- name: "Read JSON" |
| 29 | + # uses: actions/github-script@v6 |
| 30 | + # id: check-env |
| 31 | + # with: |
| 32 | + # result-encoding: string |
| 33 | + # script: | |
| 34 | + # try { |
| 35 | + # const fs = require('fs') |
| 36 | + # const jsonString = fs.readFileSync('./xmllint.json') |
| 37 | + # var config = JSON.parse(jsonString) |
| 38 | + # } catch(err) { |
| 39 | + # core.error("Error while reading or parsing the JSON") |
| 40 | + # core.setFailed(err) |
| 41 | + # } |
| 42 | + |
| 43 | + - name: Checkout Code |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + repository: ${{ inputs.repository }} |
| 48 | + ref: ${{ inputs.ref }} |
| 49 | + |
| 50 | + - name: Read JSON file # this puts the whole JSON file in the read-json step output |
| 51 | + id: read-json |
| 52 | + run: | # to read multi-line JSON file and not bother with escaping |
| 53 | + if test -f "${{ inputs.config_file }}"; then |
| 54 | + echo "config<<EOF" >> $GITHUB_OUTPUT |
| 55 | + cat ${{ inputs.config_file }} >> $GITHUB_OUTPUT |
| 56 | + echo "EOF" >> $GITHUB_OUTPUT |
| 57 | + else |
| 58 | + echo "config={}" >> $GITHUB_OUTPUT |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Lint XML |
| 62 | + run: | |
| 63 | + echo ${{ strContains(fromJson(steps.read-json.outputs.config).ignore, 'bullshit') }} |
| 64 | + echo ${{ strContains(fromJson(steps.read-json.outputs.config).ignore, '/path/to/file') }} |
0 commit comments