forked from AdarshRawat1/P4c-Documentation-Hosting
-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (157 loc) · 7.81 KB
/
deploy.yml
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Build Doxygen and Deploy to GitHub Pages
permissions:
actions: read
contents: write
pages: write
issues: write
pull-requests: write
on:
push:
branches:
- Deploy-branch-Awsome-CSS
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, labeled]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
DOXYGEN_VERSION: 1.12.0
DOXYGEN_AWESOME_VERSION: 2.3.3
PR_PATH: pr-preview/${{ github.event.number }}
DOMAIN: ${{ github.event.pull_request.base.repo.owner.login }}.github.io
DEPLOYMENT: '<img src="https://github.com/user-attachments/assets/f94fada5-45ca-4271-9106-180728235ad2" alt="Rocket" width="25"/>'
CELEBRATION: '<img src="https://github.com/user-attachments/assets/86eb8470-c597-4f8b-a77d-a54036075271" alt="githubloading" width="25"/>'
FAILURE_ICON: '<img src="https://github.com/user-attachments/assets/af921ba9-953d-465e-b597-64ed0a2dc921" alt="failed" width="25"/>'
COMMENT_IDENTIFIER: '<!-- preview-comment -->'
concurrency: ci-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Check PR Label
id: check-label
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/github-script@v6
with:
script: |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const hasDocumentationLabel = labels.some(label => label.name === 'documentation');
return hasDocumentationLabel;
- name: Find Existing Comment
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' }}
id: find-comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: ${{ env.COMMENT_IDENTIFIER }}
- name: Post Initial Comment
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' && steps.find-comment.outputs.comment-id == '' }}
id: post-initial-comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
**Deployment of preview started...** ${{ env.DEPLOYMENT }}
${{ env.COMMENT_IDENTIFIER }}
reactions: rocket
- name: Update Comment to In-Progress
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' && steps.find-comment.outputs.comment-id != '' }}
id: update-in-progress-comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
**Deployment in progress...** ${{ env.DEPLOYMENT }}
${{ env.COMMENT_IDENTIFIER }}
edit-mode: replace
- name: Find Existing Comment
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' }}
id: find-comment2
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: ${{ env.COMMENT_IDENTIFIER }}
- name: Install Clang
if: ${{ github.event_name == 'push' || steps.check-label.outputs.result == 'true' }}
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Install Doxygen
if: ${{ github.event_name == 'push' || steps.check-label.outputs.result == 'true'}}
run: |
wget https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
tar xzvf doxygen-${{ env.DOXYGEN_VERSION }}.linux.bin.tar.gz
cd doxygen-${{ env.DOXYGEN_VERSION }}
sudo make install
cd ..
rm -rf doxygen-${{ env.DOXYGEN_VERSION }}*
- name: Install Graphviz
if: ${{ github.event_name == 'push' || steps.check-label.outputs.result == 'true' }}
run: sudo apt-get install graphviz -y
- name: Clone Doxygen Awesome CSS Themes
if: ${{ github.event_name == 'push' || steps.check-label.outputs.result == 'true'}}
working-directory: ./docs/doxygen
run: |
git clone --depth 1 -b v${{ env.DOXYGEN_AWESOME_VERSION }} https://github.com/jothepro/doxygen-awesome-css awesome_css
- name: Generate Doxygen Documentation
if: ${{ github.event_name == 'push' || steps.check-label.outputs.result == 'true'}}
run: |
cd docs/doxygen
doxygen doxygen.cfg
- name: Create .nojekyll
if: ${{ github.event_name == 'push' || steps.check-label.outputs.result == 'true'}}
run: |
cd docs/doxygen/build/html
touch .nojekyll
- name: Deploy to GitHub Pages (Main Branch)
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/Deploy-branch-Awsome-CSS' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: docs/doxygen/build/html
clean: true
clean-exclude: |
pr-preview/
- name: Deploy to PR preview
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: docs/doxygen/build/html
target-folder: ${{ env.PR_PATH }}
clean: false
- name: Update Comment with Preview Link
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment2.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
| ${{ env.CELEBRATION }} **A preview of this PR is available at:** | [Preview Link](https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/${{ env.PR_PATH }}/) |
| -- | -- |
| 📂 **View the source code here:** | [View Source Code](https://github.com/${{ github.repository }}/tree/gh-pages/pr-preview/${{ github.event.pull_request.number }}) |
| 🔧 **Commit used for deployment:** | [${{ github.event.pull_request.head.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}) |
**Note:** Changes may take a few seconds to appear on GitHub Pages. Please refresh the page if you do not see the updates immediately.
${{ env.COMMENT_IDENTIFIER }}
edit-mode: replace
- name: Update Comment with Failure Message
if: ${{ github.event_name == 'pull_request_target' && steps.check-label.outputs.result == 'true' && failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment2.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
${{ env.FAILURE_ICON }} **Deployment of this PR failed.** Please check the [Actions logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details.
${{ env.COMMENT_IDENTIFIER }}
edit-mode: replace