|
| 1 | +--- |
| 2 | + |
| 3 | +name: 'Ansible Collection' |
| 4 | + |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - '**' |
| 10 | + tags: |
| 11 | + - '*' |
| 12 | + |
| 13 | + |
| 14 | +jobs: |
| 15 | + |
| 16 | + |
| 17 | + lint: |
| 18 | + name: 'Lint' |
| 19 | + env: |
| 20 | + MDLINT_PATHS: '"docs/*.md docs/**/*.md docs/**/**/*.md docs/**/**/**/*.md docs/**/**/**/**/**/*.md #CHANGELOG.md !gitlab-ci !website-template"' |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + |
| 24 | + |
| 25 | + - name: Checkout Code - ${{ github.ref_name }} |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + |
| 29 | + - name: Init Git Submodules |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + git submodule update --init; |
| 33 | + git submodule foreach git submodule update --init; |
| 34 | +
|
| 35 | + ls -ls |
| 36 | +
|
| 37 | +
|
| 38 | + - name: Install Dependencies |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + sudo apt update; |
| 42 | + sudo apt install -y --no-install-recommends npm; |
| 43 | +
|
| 44 | +
|
| 45 | + - name: Install Linter |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + npm install [email protected] --global |
| 49 | + npm install markdownlint-cli2-formatter-junit --global |
| 50 | +
|
| 51 | +
|
| 52 | + - name: Create Artifact directory |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + mkdir -p artifacts |
| 56 | +
|
| 57 | +
|
| 58 | + - name: Add linting rules |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + if [ ! -f ".markdownlint.json" ]; then |
| 62 | +
|
| 63 | + ls -la website-template; |
| 64 | +
|
| 65 | + cp "website-template/.markdownlint.json" ".markdownlint.json"; |
| 66 | +
|
| 67 | + fi; |
| 68 | +
|
| 69 | + if [ ! -f ".markdownlint-cli2.jsonc" ]; then |
| 70 | +
|
| 71 | + ls -la gitlab-ci/lint |
| 72 | +
|
| 73 | + cp -f "gitlab-ci/lint/.markdownlint-cli2.jsonc" ".markdownlint-cli2.jsonc"; |
| 74 | +
|
| 75 | + fi |
| 76 | +
|
| 77 | + ls -la; |
| 78 | +
|
| 79 | +
|
| 80 | + - name: Lint |
| 81 | + id: lint |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + markdownlint-cli2 $MDLINT_PATHS 1>&1 || EXITCODE=$? |
| 85 | +
|
| 86 | + if [ "${EXITCODE}" ]; then |
| 87 | +
|
| 88 | + echo "exit_code=${EXITCODE}" >> $GITHUB_OUTPUT |
| 89 | +
|
| 90 | + else |
| 91 | +
|
| 92 | + echo "exit_code=0" >> $GITHUB_OUTPUT |
| 93 | +
|
| 94 | + fi |
| 95 | +
|
| 96 | + echo "[Trace] GITHUB_OUTPUT[$(cat $GITHUB_OUTPUT)]"; |
| 97 | +
|
| 98 | + ls -la; |
| 99 | + |
| 100 | + mv -vf markdown.junit.xml "artifacts/markdown_lint.junit.xml" |
| 101 | +
|
| 102 | +
|
| 103 | + - name: debug ls |
| 104 | + if: ${{ success() || failure() }} |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + ls -la artifacts/; |
| 108 | +
|
| 109 | +
|
| 110 | + - name: Check if Linting Error Occured |
| 111 | + shell: bash |
| 112 | + run: | |
| 113 | + if [ ${{ steps.lint.outputs.exit_code }} -ge 3 ]; then |
| 114 | +
|
| 115 | + echo "[Error] ansible lint failed with ${{ steps.lint.outputs.exit_code }}"; |
| 116 | + |
| 117 | + exit ${{ steps.lint.outputs.exit_code }}; |
| 118 | +
|
| 119 | + fi # don't fail the job?? 1=failed test, 2=failed command i.e. switch/flag |
| 120 | +
|
| 121 | +
|
| 122 | + - name: Upload build Artifact |
| 123 | + if: ${{ success() || failure() }} |
| 124 | + uses: actions/upload-artifact@v4 |
| 125 | + with: |
| 126 | + name: mkdocs-lint |
| 127 | + path: artifacts/ |
| 128 | + |
| 129 | + |
| 130 | + - name: Should the Job be force failed? |
| 131 | + shell: bash |
| 132 | + run: | |
| 133 | + if [ "0${{ inputs.ANSIBLE_LINTING_MUST_PASS }}" == "0true" ]; then |
| 134 | +
|
| 135 | + if [ ${{ steps.lint.outputs.exit_code }} -gt 0 ]; then |
| 136 | +
|
| 137 | + echo "[Trace] ANSIBLE_LINTING_MUST_PASS[${{ inputs.ANSIBLE_LINTING_MUST_PASS }}]"; |
| 138 | + |
| 139 | + echo "[Error] ansible lint failed with ${{ steps.lint.outputs.exit_code }}"; |
| 140 | + |
| 141 | + exit ${{ steps.lint.outputs.exit_code }}; |
| 142 | + |
| 143 | + fi |
| 144 | +
|
| 145 | + fi |
| 146 | +
|
| 147 | +
|
| 148 | + lint-reports: |
| 149 | + name: 'Linting Reports' |
| 150 | + if: success() || failure() |
| 151 | + needs: |
| 152 | + - lint |
| 153 | + runs-on: ubuntu-latest |
| 154 | + steps: |
| 155 | + |
| 156 | + |
| 157 | + - name: Markdown Lint Report |
| 158 | + if: success() || failure() |
| 159 | + uses: dorny/test-reporter@v1 |
| 160 | + with: |
| 161 | + artifact: mkdocs-lint |
| 162 | + name: Markdown Lint Report |
| 163 | + path: 'markdown_lint.junit.xml' |
| 164 | + reporter: java-junit |
| 165 | + |
| 166 | + |
| 167 | + # build: |
| 168 | + # name: Build |
| 169 | + # if: false |
| 170 | + # needs: |
| 171 | + # - lint |
| 172 | + # runs-on: ubuntu-latest |
| 173 | + # steps: |
| 174 | + |
| 175 | + |
| 176 | + # - name: Debug |
| 177 | + # shell: bash |
| 178 | + # run: | |
| 179 | + |
| 180 | + # echo "To be created"; |
| 181 | + |
| 182 | + |
| 183 | + # publish: |
| 184 | + # name: Publish to Galaxy |
| 185 | + # if: false |
| 186 | + # needs: |
| 187 | + # - lint |
| 188 | + # - build |
| 189 | + # runs-on: ubuntu-latest |
| 190 | + # steps: |
| 191 | + |
| 192 | + |
| 193 | + # - name: to be created |
| 194 | + # shell: bash |
| 195 | + # run: | |
| 196 | + # echo "to be created"; |
| 197 | + |
| 198 | + |
| 199 | + # release: |
| 200 | + # if: false |
| 201 | + # needs: |
| 202 | + # - publish |
| 203 | + # name: Mark Release Live |
| 204 | + # runs-on: ubuntu-latest |
| 205 | + # steps: |
| 206 | + |
| 207 | + |
| 208 | + # - name: to be created |
| 209 | + # shell: bash |
| 210 | + # run: | |
| 211 | + # echo "to be created"; |
| 212 | + |
| 213 | + # # - name: Publish Release |
| 214 | + # # uses: grzegorzkrukowski/action-publish-github-release@v1 |
| 215 | + # # with: |
| 216 | + # # tag_name: ${{ github.ref_name }} |
| 217 | + # # token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments