-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (114 loc) · 4.16 KB
/
deploy-docs.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
---
name: Deploy docs to Azure Storage static site
on:
push:
branches:
- main
paths:
- 'terraform/**'
- '.github/workflows/deploy-docs.yml'
- 'docs/**'
- 'includes/**'
- 'useful_docs/**'
- 'mkdocs.yml'
workflow_dispatch:
jobs:
build-docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: '3.12.3'
- name: install mkdocs
run: python3 -m pip install mkdocs mkdocs-material pymdown-extensions
- name: build docs
run: mkdocs build -d site/
- name: Upload site directory
uses: actions/upload-artifact@v4
with:
name: site
path: site/
retention-days: 1
- name: Upload useful_docs directory
uses: actions/upload-artifact@v4
with:
name: useful_docs
path: useful_docs/
retention-days: 1
build-infra:
runs-on: ubuntu-latest
needs: build-docs
permissions:
contents: read
outputs:
storage_account: ${{ steps.run-tf.outputs.STORAGE_ACCOUNT_NAME }}
cdn_profile: ${{ steps.run-tf.outputs.CDN_PROFILE_NAME }}
cdn_endpoint: ${{ steps.run-tf.outputs.CDN_ENDPOINT_NAME }}
resource_group: ${{ steps.run-tf.outputs.RESOURCE_GROUP_NAME }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Download site directory
uses: actions/download-artifact@v4
with:
name: site
path: site/
- name: Deploy terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.5
terraform_wrapper: false
- name: Terraform version
run: terraform -version
- name: Run terraform
id: run-tf
env:
ARM_ACCESS_KEY: ${{ secrets.ARM_ACCESS_KEY }}
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
cd terraform/
terraform init
terraform apply -auto-approve
echo "STORAGE_ACCOUNT_NAME=$(terraform output -raw storage_account_name)" >> $GITHUB_OUTPUT
echo "CDN_PROFILE_NAME=$(terraform output -raw cdn_profile_name)" >> $GITHUB_OUTPUT
echo "CDN_ENDPOINT_NAME=$(terraform output -raw cdn_endpoint_name)" >> $GITHUB_OUTPUT
echo "RESOURCE_GROUP_NAME=$(terraform output -raw resource_group_name)" >> $GITHUB_OUTPUT
push-files:
needs: [build-docs, build-infra]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Download site directory
uses: actions/download-artifact@v4
with:
name: site
path: site/
- name: Download useful_docs directory
uses: actions/download-artifact@v4
with:
name: useful_docs
path: useful_docs/
- name: Azure Login
uses: azure/login@v2
with:
creds: '{"clientId":"${{ secrets.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.ARM_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.ARM_TENANT_ID }}"}'
- name: Upload to blob storage
uses: azure/CLI@v2
with:
inlineScript: |
az storage blob upload-batch --account-name ${{ needs.build-infra.outputs.storage_account }} -d '$web' --overwrite --source ./site
az storage blob upload-batch --account-name ${{ needs.build-infra.outputs.storage_account }} -d '$web/useful_docs' --overwrite --source ./useful_docs
- name: Purge CDN endpoint
uses: azure/CLI@v2
with:
inlineScript: |
az cdn endpoint purge --content-paths "/*" --profile-name ${{ needs.build-infra.outputs.cdn_profile }} --endpoint-name ${{ needs.build-infra.outputs.cdn_endpoint }} --resource-group ${{ needs.build-infra.outputs.resource_group }}