Repository navigation
105 lines (93 loc) · 3.52 KB
/
Copy pathcode-docs.yml
File metadata and controls
105 lines (93 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# =============================================================================
# code-docs.yml — Generated Go Package Docs
#
# Runs on every push to main. Generates Go package docs via gomarkdoc and
# commits them back to docs/code/, plus uploads a retained artifact copy.
# Mirrors environments', environments-controller's, and environments-api's
# code-docs.yml.
#
# Auth:
# Uses the BlanketOps-Environments GitHub App instead of a personal-account
# PAT for checkout/push — the default GITHUB_TOKEN can't bypass this repo's
# required-status-checks on a direct push to main.
#
# This repo has no blanketops/* module dependencies (it resolves sibling
# releases at runtime via .../releases/latest/... URLs, not go.mod pins),
# so there is no private-module git config step here.
#
# The generated docs reach main through a pull request that the workflow
# opens and squash-merges itself (hack/api-pr.sh): main's `protect` ruleset
# takes changes only that way, with verified commits, and GitHub signs both
# the API commit and the squash commit.
#
# Secrets required:
# APP_CLIENT_ID, APP_PRIVATE_KEY — GitHub App credentials
# =============================================================================
name: Code Docs
on:
push:
branches:
- main
workflow_dispatch: {}
concurrency:
group: code-docs
cancel-in-progress: false
permissions:
contents: read
jobs:
godoc:
name: Generate Code Docs
runs-on: self-hosted
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_ID_PRIVATE_KEY }}
owner: blanketops
repositories: environments-cli
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: false
- name: Install gomarkdoc
run: go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest
- name: Generate docs
run: |
mkdir -p docs/code
gomarkdoc \
--output 'docs/code/{{.Dir}}.md' \
./...
- name: Commit docs
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
hack/api-pr.sh main "docs/code-${GITHUB_SHA::7}" \
"docs: auto-generate code documentation [skip ci]" docs/code/
- name: Upload docs artifact
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: godoc-${{ github.sha }}
path: docs/code/
retention-days: 30
- name: Build summary
run: |
echo "## 📚 Code Documentation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Generated from commit \`${{ github.sha }}\` on branch \`${{ github.ref_name }}\`." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
files=$(find docs/code -name "*.md" | sort)
for f in $files; do
pkg=$(basename "$f" .md)
echo "- \`${pkg}\`" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "> 📦 Download artifact \`godoc-${{ github.sha }}\` from the [Actions run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) to browse all generated docs." >> $GITHUB_STEP_SUMMARY