-
Notifications
You must be signed in to change notification settings - Fork 7
226 lines (191 loc) · 7.78 KB
/
build-commit-subfolder.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: On PR, Build, Publish to Azure Bucket
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
#env:
#SITE_DIR: ${{ github.ref }}
#SITE_DIR: subsite
on:
workflow_dispatch:
# We have another workflow for pushing directly to dev
push:
branches:
- 'dev'
tags:
- test-*
pull_request:
types: [opened, reopened]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-html:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Get branch name
id: getbr
uses: tj-actions/branch-names@v6
- name: Get the branch output
run: echo "The output of get-branch is ${{ steps.getbr.outputs.ref_branch }}"
- name: Remove last part of PR ref
uses: mad9000/actions-find-and-replace-string@3
id: findandreplace
with:
source: 'pr${{ steps.getbr.outputs.ref_branch }}'
find: '/merge'
replace: ''
- name: Get the above output
run: echo "The output of findandreplace is $Deployment_Dir"
- name: BuildHasTag
if: ${{ github.ref_type=='tag' }}
run: |
echo "Setting Deployment_Dir to tag-${{ github.ref_name }} -- ${{ github.ref_type }}"
echo "Deployment_Dir=tag-${{ github.ref_name }}" >> $GITHUB_ENV
- name: BuildHasNoTag
if: ${{ github.ref_type!='tag' }}
run: |
echo "Setting Deployment_Dir to ${{ steps.findandreplace.outputs.value }} -- BLAH"
echo "Deployment_Dir=${{ steps.findandreplace.outputs.value }}" >> $GITHUB_ENV
- name: blob
run: echo $Deployment_Dir
- name: Checkout Dev
uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: python -m pip install --upgrade pip setuptools wheel
# Needed when using more than one repo
# add 'monorepo' to mkdocs.yml file under plugins
- run: pip install mkdocs-monorepo-plugin
# Adds requirements for social plugin. Needed to automatically fill out meta data.
# add 'social' to mkdocs.yml file under plugins
- run: pip install cffi pillow cairosvg
# Material extension now part of mkdocs
- run: pip install mkdocs-material-extensions
# add mkdocs-redirects
# zoom images
- name: Install mkdocs-redirects
run: pip install mkdocs-redirects
# add lightbox
# zoom images
- name: Install MkDocs Light Box
run: pip install mkdocs-glightbox
# add multirepo to support pulling docs from other repos
- name: Install multirepo
run: pip install mkdocs-multirepo-plugin
# Commenting out material insiders install until get proper token back.
- run: pip install git+https://${{ env.GH_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: pip install mkdocs
#- run: pip install mkdocs-material
# enable when there is an Client Library dev branch
# - name: Extract branch name
# shell: bash
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# id: extract_branch
# checkout client library files
- name: Checkout Client Library
uses: actions/checkout@v3
with:
repository: 'quixio/quix-streams'
ref: 'main' # when a dev branch exists we can get the dev content
#ref: '{{ steps.extract_branch.outputs.branch }}'
path: 'client-library'
# copy client-library readme to client-library intro.md
- name: Copy and rename client library intro.md
shell: bash
run: cp client-library/README.md docs/client-library-intro.md
# copy client library images to client library intro.md
- name: Copy Client Library Quix image
shell: bash
run: cp client-library/images/quixstreams-banner.jpg docs/assets/quixstreams-banner.jpg
# copy client library images to docs/assets/client-library/
- name: Copy client library waveform image
shell: bash
run: cp -r client-library/images/. docs/assets/client-library/
# Change image URL in the copied file to new location
# sed -i 's/old-text/new-text/g' input.txt
- name: Update intro.md
shell: bash
run: "sed -i 's,https://github.com/quixio/.github/blob/main/profile,./assets,g' docs/client-library-intro.md"
# Change image paths from ./images to ./assets/client-library
- name: Update intro.md
shell: bash
run: "sed -i 's,./images,./assets/client-library/,g' docs/client-library-intro.md"
# clone the library repo
- name: Checkout Samples
uses: actions/checkout@v3
with:
repository: 'quixio/quix-samples'
ref: 'develop' # when a dev branch exists we can get the dev content
#ref: '{{ steps.extract_branch.outputs.branch }}'
path: 'samples'
# use our own GitHub Action to bring in library readme files
- name: Quix Samples readme.md importer
uses: quixio/LibraryToMKDocsReadmeMergeAction@v2.13
id: readme_importer
with:
LIBRARY_REPO_PATH: "samples"
DOCS_PATH: ""
REPLACEMENT_PLACEHOLDER: "#ConnectorsGetInsertedHere"
README_DEST: "docs/library_readmes/connectors"
- name: Output Importer Logs
run: |
for i in ${{ steps.readme_importer.outputs.logs }}; do
echo $i
done
- name: Build MkDocs Site
run: mkdocs build --no-directory-urls
env:
AccessToken: ${{ secrets.QUIX_STREAMS_ACCESS_TOKEN }}
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create container in Azure blob storage
uses: azure/CLI@v1
with:
inlineScript: |
az login --service-principal -u 172103f9-7886-4f00-a49e-621461d234e1 -p ${{ secrets.DOCSBOT_SECRET }} --tenant 07dc27cd-da6f-4de6-b83d-c4eed0a10602
az storage container create --name ${{ env.Deployment_Dir }} --public-access container --account-name quixdocsdev --auth-mode key
- name: Upload to blob storage
uses: azure/CLI@v1
with:
inlineScript: |
az login --service-principal -u 172103f9-7886-4f00-a49e-621461d234e1 -p ${{ secrets.DOCSBOT_SECRET }} --tenant 07dc27cd-da6f-4de6-b83d-c4eed0a10602
az storage blob upload-batch --overwrite true --account-name quixdocsdev --auth-mode key -d '${{ env.Deployment_Dir }}' -s site
# Azure logout
- name: logout
run: |
az logout
if: always()
- name: Echo Site URL
run: echo "Docs preview site available at https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}/index.html"
- name: Comment Site URL
uses: mshick/add-pr-comment@v2
with:
if: always()
message: |
Docs preview site available at https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}/index.html
message-failure: |
Build failed. URL was not updated.
- name: Send Slack notification
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
# For posting a rich message using Block Kit
payload: |
{
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: A build just left the launch pad\nPreview site available at https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}/index.html"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK