-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (122 loc) · 4.53 KB
/
Copy pathdocs-auto-update.yml
File metadata and controls
138 lines (122 loc) · 4.53 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Auto-Update Docs
on:
push:
branches: [main]
paths-ignore:
- "docs/**"
- "**.md"
- ".github/workflows/docs-auto-update.yml"
workflow_dispatch:
inputs:
force_update:
description: "Force update even if no code changes"
required: false
default: false
type: boolean
permissions:
checks: write
contents: write
pull-requests: write
jobs:
generate-docs:
name: Generate Docs & Diagrams
runs-on: ubuntu-latest
# Only run on main repo, not forks
if: github.repository == 'Rul1an/assay'
permissions:
checks: write
contents: write
pull-requests: write
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
fetch-depth: 0 # Full history for changelog
- name: Setup Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Install jq
run: sudo apt-get install -y jq
- name: Generate crate dependency diagram
run: |
chmod +x scripts/docs/generate-crate-deps.sh
scripts/docs/generate-crate-deps.sh
- name: Generate module map
run: |
chmod +x scripts/docs/generate-module-map.sh
scripts/docs/generate-module-map.sh
- name: Update architecture diagrams
run: |
chmod +x scripts/docs/update-architecture-docs.sh
scripts/docs/update-architecture-docs.sh
- name: Update changelog (from recent PRs)
env:
GH_TOKEN: ${{ github.token }}
run: |
chmod +x scripts/docs/update-changelog.sh
scripts/docs/update-changelog.sh
- name: Check for changes
id: changes
run: |
if git diff --quiet docs/; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
# Requires repo Settings > Actions > General > "Allow GitHub Actions to create and approve pull requests" enabled
- name: Create Pull Request
id: create_pr
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "docs: auto-update diagrams and crate info"
title: "docs: auto-update diagrams and crate info"
body: |
## Automated Documentation Update
This PR was automatically generated after a merge to main.
### Changes
- Updated crate dependency diagram
- Updated module structure map
- Updated version info in code-map.md
- Added changelog entries for recent PRs
---
*Generated by [docs-auto-update.yml](.github/workflows/docs-auto-update.yml)*
branch: docs/auto-update
add-paths: |
docs/**
delete-branch: true
labels: documentation,automated
- name: Publish required CI check for docs PR
if: steps.changes.outputs.has_changes == 'true' && steps.create_pr.outputs.pull-request-number != ''
env:
GH_TOKEN: ${{ github.token }}
CREATED_PR_NUMBER: ${{ steps.create_pr.outputs.pull-request-number }}
REPO: ${{ github.repository }}
run: |
pr_number="${CREATED_PR_NUMBER}"
head_sha="$(gh pr view "$pr_number" --json headRefOid --jq '.headRefOid')"
payload_file="$(mktemp)"
jq -n \
--arg head_sha "$head_sha" \
--arg summary "Generated docs-only update; required CI satisfied by docs-auto-update workflow." \
'{
name: "CI",
head_sha: $head_sha,
status: "completed",
conclusion: "success",
output: {
title: "CI",
summary: $summary
}
}' > "$payload_file"
gh api "repos/${REPO}/check-runs" \
--method POST \
-H "Accept: application/vnd.github+json" \
--input "$payload_file"
rm -f "$payload_file"
- name: Enable auto-merge for docs PR
if: steps.changes.outputs.has_changes == 'true' && steps.create_pr.outputs.pull-request-number != ''
env:
GH_TOKEN: ${{ github.token }}
CREATED_PR_NUMBER: ${{ steps.create_pr.outputs.pull-request-number }}
run: gh pr merge "$CREATED_PR_NUMBER" --auto --squash