-
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (113 loc) · 4.43 KB
/
wiki-maintenance.yml
File metadata and controls
139 lines (113 loc) · 4.43 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
139
name: Maintain Wiki Publication
on:
workflow_call:
permissions:
contents: read
env:
FORCE_COLOR: '1'
jobs:
publish:
name: Publish Wiki Master
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
env:
WIKI_PUBLISH_BRANCH: master
WIKI_PREVIEW_BRANCH: pr-${{ github.event.pull_request.number }}
steps:
- name: Checkout main branch
uses: actions/checkout@v6
with:
token: ${{ github.token }}
ref: main
submodules: recursive
fetch-depth: 0
- name: Mark workspace as safe for git
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory "$GITHUB_WORKSPACE/.github/wiki"
- name: Prepare wiki publish branch from preview branch
id: prepare_publish
uses: ./.github/actions/wiki/prepare-publish-branch
with:
publish-branch: ${{ env.WIKI_PUBLISH_BRANCH }}
preview-branch: ${{ env.WIKI_PREVIEW_BRANCH }}
- name: Push wiki publish branch
working-directory: .github/wiki
run: git push --force-with-lease origin HEAD:"${WIKI_PUBLISH_BRANCH}"
- name: Validate wiki publish branch
uses: ./.github/actions/wiki/validate-publish-branch
with:
publish-branch: ${{ env.WIKI_PUBLISH_BRANCH }}
preview-branch: ${{ env.WIKI_PREVIEW_BRANCH }}
expected-preview-sha: ${{ steps.prepare_publish.outputs.expected-preview-sha }}
- name: Delete wiki preview branch
uses: ./.github/actions/wiki/delete-preview-branch
with:
preview-branch: ${{ env.WIKI_PREVIEW_BRANCH }}
- uses: ./.github/actions/summary/write
with:
markdown: |
## Wiki Publish Summary
- Publish branch: `${{ env.WIKI_PUBLISH_BRANCH }}`
- Preview branch: `${{ env.WIKI_PREVIEW_BRANCH }}`
- Expected preview SHA: `${{ steps.prepare_publish.outputs.expected-preview-sha }}`
- Publish validation: completed
- Preview cleanup: `${{ env.WIKI_PREVIEW_BRANCH }}` deleted
cleanup_closed_preview:
name: Delete Closed PR Wiki Preview
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == false
runs-on: ubuntu-latest
permissions:
contents: write
env:
WIKI_PREVIEW_BRANCH: pr-${{ github.event.pull_request.number }}
steps:
- name: Checkout main branch
uses: actions/checkout@v6
with:
token: ${{ github.token }}
ref: main
submodules: recursive
fetch-depth: 0
- name: Mark wiki workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE/.github/wiki"
- name: Delete wiki preview branch
uses: ./.github/actions/wiki/delete-preview-branch
with:
preview-branch: ${{ env.WIKI_PREVIEW_BRANCH }}
- uses: ./.github/actions/summary/write
with:
markdown: |
## Wiki Preview Cleanup Summary
- Deleted preview branch: `${{ env.WIKI_PREVIEW_BRANCH }}`
- Trigger: closed pull request without merge
cleanup_orphaned_previews:
name: Delete Orphaned Wiki Previews
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout main branch
uses: actions/checkout@v6
with:
token: ${{ github.token }}
ref: main
submodules: recursive
fetch-depth: 0
- name: Mark wiki workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE/.github/wiki"
- name: Delete wiki branches for closed pull requests
id: cleanup
uses: ./.github/actions/wiki/cleanup-orphaned-previews
- uses: ./.github/actions/summary/write
with:
markdown: |
## Wiki Orphan Cleanup Summary
- Deleted preview branches: `${{ steps.cleanup.outputs.deleted || '0' }}`
- Retained preview branches: `${{ steps.cleanup.outputs.skipped || '0' }}`
- Unresolved preview branches: `${{ steps.cleanup.outputs.unresolved || '0' }}`