-
Notifications
You must be signed in to change notification settings - Fork 44
210 lines (203 loc) · 6.64 KB
/
website.yaml
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Radius Website
on:
workflow_dispatch:
push:
branches:
- edge
- v*.*
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- edge
- v*.*
jobs:
build:
name: Build Hugo Website
if: github.event.action != 'closed'
runs-on: ubuntu-latest
env:
GOVER: '^1.17'
TUTORIAL_PATH: './docs/content/user-guides/tutorials/'
CODE_ZIP_PATH: './docs/static/tutorial/'
HUGO_ENV: production
SWA_BASE: 'wonderful-plant-020417a1e'
steps:
- name: Checkout docs repo
uses: actions/checkout@v3
with:
submodules: true
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_docs_version.py
- name: Checkout radius repo
uses: actions/checkout@v3
with:
repository: project-radius/radius
ref: ${{ env.RELEASE_BRANCH }}
path: ./radius
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
- name: Setup Go ${{ env.GOVER }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GOVER }}
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Setup Hugo
uses: peaceiris/[email protected]
with:
hugo-version: 0.102.3
extended: true
- name: Setup Docsy
run: |
cd docs
sudo npm install -D --save autoprefixer
sudo npm install -D --save postcss-cli
cd themes/docsy
npm install
- name: Restore CLI Docs Cache
uses: actions/cache@v3
id: cli_cache
with:
path: |
./docs/content/reference/cli
key: ${{ runner.os }}-cli-${{ hashFiles('radius/pkg/cli') }}
- name: Restore Go Modules Cache
uses: actions/cache@v3
if: steps.cli_cache.outputs.cache-hit != 'true'
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('radius/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate CLI Docs
run: |
if [ ! -f ./docs/content/reference/cli/rad.md ]; then
cd radius
go run ./cmd/docgen/main.go ../docs/content/reference/cli
fi
- name: Generate Swagger docs
run : |
mkdir -p ./docs/static/swagger
cp -r ./radius/swagger ./docs/static/
- name: Build Hugo Site
run: |
cd docs
if [ $GITHUB_EVENT_NAME == 'pull_request' ]; then
STAGING_URL="https://${SWA_BASE}-${{github.event.number}}.westus2.azurestaticapps.net/"
fi
hugo ${STAGING_URL+-b "$STAGING_URL"}
- name: Upload Hugo artifacts
uses: actions/upload-artifact@v3
with:
name: hugo_build
path: ./docs/public/
if-no-files-found: error
deploy:
name: Deploy Hugo Website
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: ['build']
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name == 'edge' && 'edge' || 'latest' }}
url: ${{ github.ref_name == 'edge' && 'https://edge.docs.radapp.dev' || 'https://docs.radapp.dev' }}
steps:
- name: Checkout docs repo
uses: actions/checkout@v3
with:
submodules: false
- name: Download Hugo artifacts
uses: actions/download-artifact@v3
with:
name: hugo_build
path: site/
- name: az CLI login
run: |
az login --service-principal \
--username ${{ secrets.AZURE_SP_TESTS_APPID }} \
--password ${{ secrets.AZURE_SP_TESTS_PASSWORD }} \
--tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }}
az account set --subscription ${{ vars.ENV_APPSERVICE_SUBSCRIPTIONID }}
- name: Deploy to WebApp
uses: Azure/webapps-deploy@v2
with:
app-name: ${{ vars.ENV_APPSERVICE_NAME }}
resource-group-name: ${{ vars.ENV_APPSERVICE_RESOURCEGROUP }}
package: site/
open_staging_site:
name: Open Staging Site
needs: ['build']
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Download Hugo artifacts
uses: actions/download-artifact@v3
with:
name: hugo_build
path: site/
- name: Deploy staging site
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.STAGING_DOCS_SITE_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "site/"
api_location: "site/"
output_location: ""
skip_app_build: true
- name: Find SWA Comment
uses: peter-evans/find-comment@v2
id: fc
if: github.event_name == 'pull_request'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Azure Static Web Apps:'
direction: last
- name: Update SWA Comment
if: github.event_name == 'pull_request' && steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
**Password**: `Radiu$1234`
close_pr_site:
name: Close PR Staging Site
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.STAGING_DOCS_SITE_TOKEN }}
action: "close"
algolia_index:
name: Index site for Algolia
if: github.event_name == 'push'
needs: ['build', 'deploy']
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name == 'edge' && 'edge' || 'latest' }}
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_API_APPID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ENV_ALGOLIA_INDEXNAME }}
steps:
- name: Checkout docs repo
uses: actions/checkout@v2
with:
submodules: false
- name: Download Hugo artifacts
uses: actions/download-artifact@v3
with:
name: hugo_build
path: site/
- name: Install Python packages
run: |
pip install --upgrade bs4
pip install --upgrade 'algoliasearch>=2.0,<3.0'
- name: Index site
run: python ./.github/scripts/algolia.py ./site