-
Notifications
You must be signed in to change notification settings - Fork 513
62 lines (56 loc) · 2.37 KB
/
docs-deploy.yml
File metadata and controls
62 lines (56 loc) · 2.37 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
name: Deploy Doxygen
on:
workflow_run:
workflows: ["Build Doxygen"]
types: [completed]
permissions:
contents: write # Needed to push to gh-pages branch
pull-requests: write # Needed to post the comment
issues: write # Needed to post the comment
actions: read # Needed to read the build artifact
jobs:
deploy:
# Only run if the build workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download Artifact from Build
uses: actions/download-artifact@v8
with:
name: doxygen-html
path: build-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Read PR number from artifact metadata
id: pr
if: github.event.workflow_run.event == 'pull_request'
run: |
# PR number is passed via the build artifact (workflow_run.pull_requests may be empty).
pr="$(cat build-results/_meta/pr_number.txt 2>/dev/null || true)"
echo "number=$pr" >> "$GITHUB_OUTPUT"
# Don't publish internal metadata on GitHub Pages.
rm -f build-results/_meta/pr_number.txt
rmdir build-results/_meta 2>/dev/null || true
- name: Deploy to GitHub Pages (Main or PR)
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build-results
branch: gh-pages
# Logic: If triggered by a PR, use pr-preview folder, otherwise root
target-folder: >-
${{ github.event.workflow_run.event == 'pull_request'
&& steps.pr.outputs.number != ''
&& format('pr-preview/{0}', steps.pr.outputs.number)
|| '' }}
clean: ${{ github.event.workflow_run.event == 'push' }}
clean-exclude: pr-preview/
- name: Post/Update PR Comment
if: github.event.workflow_run.event == 'pull_request' && steps.pr.outputs.number != ''
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ steps.pr.outputs.number }}
body: |
🚀 **Doxygen Preview Ready!**
[Click here to view the preview](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/${{ steps.pr.outputs.number }}/)