Skip to content

Commit 91ea39a

Browse files
committed
(PUP-12055) Build references on commit to main
When a commit is pushed to main, build all of the references, including man pages. If the only changes are due to SHA and dates, then do nothing. Otherwise, commit all of the references and man pages. The action is only triggered when a commit is pushed to main, but not on pull requests so that we don't have to worry about untrusted inputs. The action is only triggered when the repo owner is puppetlabs, so it won't trigger on forks. The action uses full SHAs for the pandoc and add-and-commit actions. If changes are detected, the action creates a commit whose author is GitHub Actions <[email protected]> with message: Update references [no-promote] And pushes the commit to the main branch. It uses the repository's GITHUB_TOKEN to accomplish this. We don't need to worry about recursive workflow runs[1]: When you use the repository's GITHUB_TOKEN to perform tasks, events triggered by the GITHUB_TOKEN ... will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. [1] https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow
1 parent 5af02da commit 91ea39a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/references.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Generate References
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
generate_references:
14+
if: ${{ github.repository_owner == 'puppetlabs' }}
15+
runs-on: ubuntu-latest
16+
name: Generate References
17+
env:
18+
BUNDLE_WITH: "documentation"
19+
BUNDLE_WITHOUT: "features packaging"
20+
steps:
21+
- name: Checkout current PR
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Ruby
25+
uses: ruby/setup-ruby@v1
26+
with:
27+
ruby-version: 3.2
28+
bundler-cache: true
29+
30+
- name: Setup Pandoc
31+
uses: pandoc/actions/setup@d940685d5968400c91029147adbd612deb7696b0
32+
with:
33+
version: 3.1.8
34+
35+
- name: Generate References
36+
id: generate-references
37+
run: |
38+
bundle exec rake references:all
39+
git --no-pager diff --exit-code --ignore-matching-lines='This page was generated from the Puppet source' --ignore-matching-lines='built_from_commit:' man references || echo 'commit=true' >> "$GITHUB_OUTPUT"
40+
41+
- name: Commit and Push
42+
if: ${{ steps.generate-references.outputs.commit == 'true' }}
43+
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5
44+
with:
45+
author_name: GitHub Actions
46+
author_email: [email protected]
47+
message: 'Update references [no-promote]'
48+
add: 'man references'
49+
push: true
50+

0 commit comments

Comments
 (0)