-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
173 lines (161 loc) · 6.51 KB
/
action.yml
File metadata and controls
173 lines (161 loc) · 6.51 KB
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
name: "Build and Deploy Documentation Site"
description: "Convert Markdown documentation to a BCC documentation site"
inputs:
title:
description: "Title of the generated website"
required: true
default: ${{ github.event.repository.name }}
description:
description: "Description of the generated website, used for the head meta tag"
required: true
default: ${{ github.event.repository.description }}
docs-dir:
description: "Directory where the docs are located"
required: false
default: "docs"
branch:
description: 'Which branch to use for "Edit this page on GitHub" links'
required: false
default: "main"
base:
description: "The base url for the website"
required: false
default: "/"
collapse-sidebar:
description: "Whether to collapse sidebar sections by default"
required: false
default: "false"
auto-register-components:
description: "Whether to automatically register Vue components"
required: false
default: "false"
components-dir:
description: "The directory from where Vue components should automatically be registered"
required: false
default: "src/components"
debug-build:
description: "Whether or not to enable debugging for the Vite build"
required: false
default: "false"
public:
description: "Whether or not to make the documentation publicly available (only works for private repositories)"
required: false
default: "false"
authentication:
description: "Which provider to use for the login flow when accessing the documentation"
required: false
default: "github"
root:
description: "Whether or not to deploy the site to the root of the custom container (true) or to a subfolder named after the repository (false)"
required: false
default: "false"
pat:
description: "Personal Access Token for authentication"
required: true
env:
description: "Environment to deploy to (sandbox, prod)"
required: false
default: "prod"
runs:
using: "composite"
steps:
- name: Check out base repository
uses: actions/checkout@v5
with:
repository: bcc-code/bcc-developer-docs
ref: master
token: ${{ inputs.pat }}
- name: Check out current repository
uses: actions/checkout@v5
with:
path: source
- name: Zip Markdown files
shell: bash
run: |
cd source/${{ inputs.docs-dir }}
zip -r MarkdownDocs.zip .
- name: Zip Vue components (if they exist)
shell: bash
run: |
if [ -d "source/${{ inputs.components-dir }}" ]; then
cd source/${{ inputs.components-dir }}
zip -r VueComponents.zip .
fi
- name: Set domain variable
id: set-domain
shell: bash
run: |
if [ "${{ inputs.env }}" = "prod" ]; then
echo "domain=https://developer.bcc.no" >> $GITHUB_OUTPUT
else
echo "domain=https://developer.sandbox.bcc.no" >> $GITHUB_OUTPUT
fi
- name: Get Token from GitHub
id: token
shell: bash
run: |
curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://github.com/bcc-code" | jq -r ".value" | echo -e "token=$(</dev/stdin)\n" >> $GITHUB_OUTPUT
- name: Upload Markdown files to azure storage
shell: bash
run: |
curl --request POST \
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
--form Docs=@source/${{ inputs.docs-dir }}/MarkdownDocs.zip \
"${{ steps.set-domain.outputs.domain }}/UploadMdContainer?aggregateContainer=mddocs&root=${{inputs.root}}"
- name: Upload Vue components to azure storage (if they exist)
shell: bash
run: |
if [ -f "source/${{ inputs.components-dir }}/VueComponents.zip" ]; then
curl --request POST \
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
--form Docs=@source/${{ inputs.components-dir }}/VueComponents.zip \
"${{ steps.set-domain.outputs.domain }}/UploadDoc?isPublic=false&customContainerName=components"
fi
- name: Download Markdown files from azure storage
shell: bash
run: |
cd vuepress/docs/
curl --request GET \
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
"${{ steps.set-domain.outputs.domain }}/GetDoc?container=mddocs" \
--output MarkdownDocs.zip
unzip -o MarkdownDocs.zip
rm MarkdownDocs.zip
mv bcc-developer-docs/* .
rm -rf bcc-developer-docs
- name: Download Vue components from azure storage
shell: bash
run: |
mkdir -p vuepress/docs/.vuepress/auto-register-components
cd vuepress/docs/.vuepress/auto-register-components
curl --request GET \
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
"${{ steps.set-domain.outputs.domain }}/GetDoc?container=components" \
--output VueComponents.zip
if [ -f "VueComponents.zip" ]; then
unzip -o VueComponents.zip
rm VueComponents.zip
fi
- name: Build VuePress site
shell: bash
run: |
chmod -R u+rwX vuepress/docs || true
cd vuepress
npm i && ${{ inputs.debug-build == true && 'DEBUG=*' || '' }} npm run build ${{ inputs.debug-build == true && '-- --debug' || '' }}
- name: Zips built site files
shell: bash
run: |
cd vuepress/docs/.vuepress/dist
zip -r Docs.zip .
- name: Upload VuePress site
shell: bash
run: |
curl --request POST \
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
--form Docs=@vuepress/docs/.vuepress/dist/Docs.zip \
"${{ steps.set-domain.outputs.domain }}/UploadDoc?customContainerName=docs"