-
-
Notifications
You must be signed in to change notification settings - Fork 38
95 lines (83 loc) · 3.19 KB
/
docs-version-sync.yml
File metadata and controls
95 lines (83 loc) · 3.19 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
name: Sync Docs Version
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g. v2.87.2)'
required: true
permissions:
contents: write
pull-requests: write
jobs:
sync-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Get release version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "push" ]; then
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
fi
- name: Close previous version-sync PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr list --state open --search "docs: sync version to" --json number,headRefName --jq '.[]' | while read -r line; do
pr_num=$(echo "$line" | jq -r '.number')
branch=$(echo "$line" | jq -r '.headRefName')
gh pr close "$pr_num" --comment "Superseded by ${{ steps.version.outputs.VERSION }}" --delete-branch || true
done
- name: Run version sync script
run: ./scripts/docs-version-sync.sh ${{ steps.version.outputs.VERSION }}
- name: Warn if PAT missing
env:
HAS_PAT: ${{ secrets.PILOT_DOCS_PAT != '' }}
run: |
if [ "$HAS_PAT" != "true" ]; then
echo "::warning::PILOT_DOCS_PAT not set — auto-merge will use GITHUB_TOKEN, sync-docs.yml will not chain"
fi
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.changes.outputs.changed == 'true'
id: pr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PILOT_DOCS_PAT || secrets.GITHUB_TOKEN }}
commit-message: "docs: sync version to ${{ steps.version.outputs.VERSION }}"
title: "docs: sync version to ${{ steps.version.outputs.VERSION }}"
body: |
Automated PR to update version references in Navigator docs after release.
Updated files:
- `.agent/DEVELOPMENT-README.md`
- `.agent/system/FEATURE-MATRIX.md`
- `docs/app/layout.tsx` (navbar version)
- `docs/lib/version.ts` (`<CurrentVersion/>` source of truth)
Created by docs-version-sync workflow.
branch: docs/version-sync-${{ steps.version.outputs.VERSION }}
base: main
labels: documentation
- name: Enable auto-merge
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.PILOT_DOCS_PAT || secrets.GITHUB_TOKEN }}
run: |
if [ -n "${{ steps.pr.outputs.pull-request-number }}" ]; then
gh pr merge "${{ steps.pr.outputs.pull-request-number }}" --auto --squash
fi