/
action.yml
183 lines (153 loc) · 5.91 KB
/
action.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
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
# Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: >
Doc deploy index action
description: |
This action automates the process of creating indexes and scraping the
HTML documentation artifact that contains the development version
of a library, then deploying it to a Meilisearch instance.
inputs:
# Required inputs
cname:
description: >
The CNAME (canonical Name) that points to the documentation website for a specific version,
specifically intended for scraping purposes.
The format of the CNAME should be "cname/version/version-number," where:
- "cname" is the main Canonical Name
- "version-number" is the specific number associated with the version (e.g., 0.1, 0.2, 0.3).
required: true
type: string
index-name:
description: >
The identifier given to the documentation in pymeilisearch.
required: true
type: string
api-key:
description: >
The API key used to access the Meilisearch instance host.
required: true
type: string
host-url:
description: >
The URL where the Meilisearch instance is hosted.
required: true
type: string
# Optional inputs
python-version:
description: >
Python version used for execution of the stable docs scraping.
default: '3.10'
required: false
type: string
doc-artifact-name:
description: >
The name of the HTML documentation artifact. This artifact is expected to
contain all the HTML and static files.The dafault value is ``documentation-html``.
required: false
default: 'documentation-html'
type: string
template:
description: >
The "template" parameter specifies the layout used for the HTML documentation.
By default, it is set to ``sphinx_pydata`` which assumes that the document is
constructed using the pydata-sphinx-theme or its associated theme,
such as the ansys-sphinx-theme.
required: false
default: "sphinx_pydata"
type: string
decompress-artifact:
description: >
Whether to decompress the ``doc-artifact-name`` file using `ouch
<https://github.com/ouch-org/ouch>`_ as decompression tool. Default value
is ``false``.
required: false
default: false
type: string
pymeilisearchopts:
description: >
A list of pyemeilisearch options when scraping URLs. See
`pymeilisearch user guide <https://pymeilisearch.docs.ansys.com/version/stable/user-guide/index.html>`_
for available options
default: ''
required: false
type: string
runs:
using: "composite"
steps:
- name: "Set up Python"
uses: ansys/actions/_setup-python@v6
with:
python-version: ${{ inputs.python-version }}
# ------------------------------------------------------------------------
- uses: ansys/actions/_logging@v6
with:
level: "INFO"
message: >
Download the documentation artifact from the current workflow.
- name: "Download the development documentation artifact"
uses: actions/download-artifact@v4
with:
name: ${{ inputs.doc-artifact-name }}
path: ${{ inputs.doc-artifact-name }}
- name: "Update apt-get"
shell: bash
run: |
sudo apt-get update
- name: "Decompress artifact content"
shell: bash
if: inputs.decompress-artifact == 'true'
run: |
sudo apt-get install -y cargo && cargo install ouch
export PATH="$HOME/.cargo/bin/:$PATH"
ouch --version
cd ${{ inputs.doc-artifact-name }} && compressed_artifact=$(ls .)
ouch decompress $compressed_artifact
decompressed_artifact=$(ls -I "*${compressed_artifact##*.}")
mv $decompressed_artifact/* .
rm -rf $compressed_artifact $decompressed_artifact
- name: "Display structure of ${{ inputs.doc-artifact-name }}"
shell: bash
run: |
ls -R ${{ inputs.doc-artifact-name }}
# ------------------------------------------------------------------------
- uses: ansys/actions/_logging@v6
with:
level: "INFO"
message: >
Install the pymeilisearch required for the indexing.
- name: "Install build and twine"
shell: bash
run: |
python -m pip install pymeilisearch
# ------------------------------------------------------------------------
- uses: ansys/actions/_logging@v6
with:
level: "INFO"
message: >
Scrap the document and deploy it to pymeilisearch.
- name: Scrape the dev documentation to meilisearch
shell: bash
run: |
pymeilisearch upload --template ${{ inputs.template }} --index ${{ inputs.index-name }} --cname ${{ inputs.cname }} html ${{ inputs.doc-artifact-name }} ${{ inputs.pymeilisearchopts }}
env:
MEILISEARCH_HOST_URL: ${{ inputs.host-url }}
MEILISEARCH_API_KEY: ${{ inputs.api-key }}