Skip to content

Commit 04c308e

Browse files
authored
add some sample workflows (#47)
1 parent 8979a3d commit 04c308e

File tree

5 files changed

+241
-0
lines changed

5 files changed

+241
-0
lines changed

samples/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Samples
2+
3+
These are samples of workflows you can add to your repository to use the actions and workflows in this repository, to build Ansible docs for your collection.
4+
5+
They are mostly ready to go, but can be customized to your needs. See the [wiki pages](https://github.com/ansible-community/github-docs-build/wiki) to browse the full options for each workflow and action.
6+
7+
The shared workflows in this repository make use of the actions in this repository, and you can use those reusable workflows as-is, or use them as a basis for creating your own workflows that do things a bit differently.
8+
9+
Your repository's workflow can combine jobs that use reusable workflows, and traditional job definitions with your own steps, so there is a lot of flexibility to be had. The workflows and actions here are meant to be modular in that way.

samples/pr-build-and-comment.yml

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

samples/push-with-build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# A simple workflow that runs a strict build against pushes
2+
# to main, stable branches, and tags, and also runs once a day.
3+
# This ensures ongoing healthy, buildable docs.
4+
name: Collection Docs
5+
concurrency:
6+
group: docs-push-${{ github.sha }}
7+
cancel-in-progress: true
8+
on:
9+
push:
10+
branches:
11+
- main
12+
- stable-*
13+
tags:
14+
- '*'
15+
schedule:
16+
- cron: '0 13 * * *'
17+
18+
jobs:
19+
build-docs:
20+
permissions:
21+
contents: read
22+
name: Build Ansible Docs
23+
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-push.yml@main
24+
with:
25+
init-lenient: false
26+
init-fail-on-error: true
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Collection Docs
2+
concurrency:
3+
group: docs-push-${{ github.sha }}
4+
cancel-in-progress: true
5+
on:
6+
push:
7+
branches:
8+
- main
9+
tags:
10+
- '*'
11+
schedule:
12+
- cron: '0 13 * * *'
13+
14+
jobs:
15+
build-docs:
16+
permissions:
17+
contents: read
18+
name: Build Ansible Docs
19+
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-push.yml@main
20+
with:
21+
init-lenient: false
22+
init-fail-on-error: true
23+
24+
publish-docs-gh-pages:
25+
# use to prevent running on forks
26+
if: github.repository == 'repo_owner/repo_name'
27+
permissions:
28+
contents: write
29+
needs: [build-docs]
30+
name: Publish Ansible Docs
31+
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-publish-gh-pages.yml@main
32+
with:
33+
artifact-name: ${{ needs.build-docs.outputs.artifact-name }}
34+
secrets:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)