|
| 1 | +name: Collection Docs |
| 2 | +concurrency: |
| 3 | + group: docs-pr-${{ github.head_ref }} |
| 4 | + cancel-in-progress: true |
| 5 | +on: |
| 6 | + pull_request_target: |
| 7 | + types: [opened, synchronize, reopened, closed] |
| 8 | + |
| 9 | +env: |
| 10 | + GHP_BASE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }} |
| 11 | + |
| 12 | +jobs: |
| 13 | + # Validation job runs a strict build to ensure it will fail CI on any mistakes. |
| 14 | + validate-docs: |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + name: Validate Ansible Docs |
| 18 | + if: github.event.action != 'closed' |
| 19 | + uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-push.yml@main |
| 20 | + with: |
| 21 | + artifact-upload: false |
| 22 | + init-lenient: false |
| 23 | + init-fail-on-error: true |
| 24 | + build-ref: refs/pull/${{ github.event.number }}/merge |
| 25 | + |
| 26 | + # The build job runs with the most lenient settings to ensure the best chance of getting |
| 27 | + # a rendered docsite that can be looked at. |
| 28 | + build-docs: |
| 29 | + permissions: |
| 30 | + contents: read |
| 31 | + name: Build Ansible Docs |
| 32 | + uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-pr.yml@main |
| 33 | + with: |
| 34 | + init-lenient: true |
| 35 | + init-fail-on-error: false |
| 36 | + render-file-line: '> * `$<status>` [$<path_tail>](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr/${{ github.event.number }}/$<path_tail>)' |
| 37 | + |
| 38 | + publish-docs-gh-pages: |
| 39 | + # use to prevent running on forks |
| 40 | + if: github.repository == 'repo_owner/repo_name' |
| 41 | + permissions: |
| 42 | + contents: write |
| 43 | + needs: [build-docs] |
| 44 | + name: Publish Ansible Docs |
| 45 | + uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-publish-gh-pages.yml@main |
| 46 | + with: |
| 47 | + artifact-name: ${{ needs.build-docs.outputs.artifact-name }} |
| 48 | + action: ${{ (github.event.action == 'closed' || needs.build-docs.outputs.changed != 'true') && 'teardown' || 'publish' }} |
| 49 | + secrets: |
| 50 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + comment: |
| 53 | + permissions: |
| 54 | + pull-requests: write |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: [publish-docs-gh-pages, build-docs] |
| 57 | + name: PR comments |
| 58 | + steps: |
| 59 | + - name: PR comment |
| 60 | + uses: ansible-community/github-docs-build/actions/ansible-docs-build-comment@main |
| 61 | + with: |
| 62 | + body-includes: '## Docs Build' |
| 63 | + reactions: heart |
| 64 | + action: ${{ needs.build-docs.outputs.changed != 'true' && 'remove' || '' }} |
| 65 | + on-closed-action: remove |
| 66 | + on-merged-body: | |
| 67 | + ## Docs Build 📝 |
| 68 | +
|
| 69 | + Thank you for contribution!✨ |
| 70 | +
|
| 71 | + This PR has been merged and the docs are now incorporated into `main`: |
| 72 | + ${{ env.GHP_BASE_URL }}/branch/main |
| 73 | + body: | |
| 74 | + ## Docs Build 📝 |
| 75 | +
|
| 76 | + Thank you for contribution!✨ |
| 77 | +
|
| 78 | + The docs for **this PR** have been published here: |
| 79 | + ${{ env.GHP_BASE_URL }}/pr/${{ github.event.number }} |
| 80 | +
|
| 81 | + You can compare to the docs for the `main` branch here: |
| 82 | + ${{ env.GHP_BASE_URL }}/branch/main |
| 83 | +
|
| 84 | + The docsite for **this PR** is also available for download as an artifact from this run: |
| 85 | + ${{ needs.build-docs.outputs.artifact-url }} |
| 86 | +
|
| 87 | + File changes: |
| 88 | +
|
| 89 | + ${{ needs.build-docs.outputs.diff-files-rendered }} |
| 90 | +
|
| 91 | + ${{ needs.build-docs.outputs.diff-rendered }} |
0 commit comments