-
Notifications
You must be signed in to change notification settings - Fork 44
188 lines (181 loc) · 6.69 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
name: Radius Website
on:
workflow_dispatch:
push:
branches:
- edge
- v*.*
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- edge
- v*.*
permissions:
id-token: write # Required for requesting the JWT
contents: read # Required for actions/checkout
jobs:
build:
name: Build Hugo Website
if: github.event.action != 'closed'
runs-on: ubuntu-latest
environment:
# If a PR into edge, use 'edge'. If a PR into anywhere else, use 'latest'. If a push, use the branch name.
name: ${{ github.event_name == 'pull_request' && (github.base_ref == 'edge' && 'edge' || 'latest') || github.ref_name }}
env:
GOVER: '^1.17'
TUTORIAL_PATH: './docs/content/user-guides/tutorials/'
CODE_ZIP_PATH: './docs/static/tutorial/'
HUGO_VERSION: 0.117.0
HUGO_ENV: production
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: radius-project/radius
ref: ${{ env.RELEASE_BRANCH }}
path: ./radius
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Setup Hugo
uses: peaceiris/[email protected]
with:
hugo-version: ${{ env.HUGO_VERSION }}
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: Generate Swagger docs
run : |
mkdir -p ./docs/static/swagger
cp -r ./radius/swagger ./docs/static/
- name: Override git_branch for PR
if: github.event_name == 'pull_request'
run: |
# Within docs/config.toml, replace the line that starts with "github_branch" with "github_branch: $GITHUB_HEAD_REF"
sed -i "s|github_branch = .*|github_branch = \"$GITHUB_HEAD_REF\"|" docs/config.toml
- name: Build Hugo Site
run: |
cd docs
if [ $GITHUB_EVENT_NAME == 'pull_request' ]; then
STAGING_URL="https://${{ vars.ENV_STATICWEBAPP_BASE }}-${{github.event.number }}.westus2.3.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 to App Service
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: ['build']
runs-on: ubuntu-latest
environment:
# If push to edge, use 'edge'. If push to anywhere else, use 'latest'.
name: ${{ github.ref_name == 'edge' && 'edge' || 'latest' }}
url: ${{ github.ref_name == 'edge' && 'https://edge.docs.radapp.io' || 'https://docs.radapp.io' }}
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: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_SP_TESTS_APPID }}
tenant-id: ${{ secrets.AZURE_SP_TESTS_TENANTID }}
subscription-id: ${{ 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/
deploy-website:
name: Deploy Hugo Website
needs: ['build']
runs-on: ubuntu-latest
environment:
# If a PR or push into edge, use 'edge'. If a PR or push into anywhere else, use 'latest'.
name: ${{ github.event_name == 'pull_request' && (github.base_ref == 'edge' && 'edge' || 'latest') || (github.ref_name == 'edge' && 'edge' || 'latest') }}
# If a push to edge, use the edge URL. If a push to anywhere else, use the latest URL. If a PR, blank.
url: ${{ github.event_name == 'pull_request' && '' || (github.ref_name == 'edge' && 'https://edge.docs.radapp.io' || 'https://docs.radapp.io') }}
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.ENV_STATICWEBAPP_TOKEN }}
skip_deploy_on_missing_secrets: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "site/"
api_location: "site/"
output_location: ""
skip_app_build: true
close_pr_site:
name: Close PR Staging Site
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
environment:
# If a PR into edge, use 'edge'. If a PR into anywhere else, use 'latest'.
name: ${{ github.base_ref == 'edge' && 'edge' || 'latest' }}
url: ${{ github.base_ref == 'edge' && 'https://edge.docs.radapp.io' || 'https://docs.radapp.io' }}
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.ENV_STATICWEBAPP_TOKEN }}
skip_deploy_on_missing_secrets: true
action: "close"
algolia_index:
name: Index site for Algolia
if: github.event_name == 'push'
needs: ['build', 'deploy']
runs-on: ubuntu-latest
environment:
# If push to edge, use 'edge'. If push to anywhere else, use 'latest'.
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