-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
88 lines (81 loc) · 3.31 KB
/
action.yml
File metadata and controls
88 lines (81 loc) · 3.31 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
name: "SQLite Cloud - docs search"
description: "Parses .md and .mdx files to create a database on your SQLite Cloud project."
author: "Gioele Cantoni"
inputs:
project-string:
description: The SQLite Cloud project connection string.
required: true
base-url:
description: Your website's documentation base url.
required: true
database:
description: The name of the database to use on SQLite Cloud, just remeber to create first a database on your project!
required: true
path:
description: The path of the markdown files, by default it will parse every .md/.mdx file recursively starting from the working directory.
required: false
default: $(pwd)
strip-html:
description: If you want to remove html elements from the search set this to true.
required: false
default: false
strip-jsx:
description: If you want to remove jsx elements from the search set this to true.
required: false
default: false
strip-md-titles:
description: If you want to avoid redundancy of your markdown titles in the search set this to true.
required: false
default: false
use-front-matter:
description: If you use a front matter and you want the action to convert it to json and send it to the cloud make this true.
required: false
default: false
path-using-slug:
description: Use the slug in the header as the path instead of the relative one.
required: false
default: false
branding:
icon: "search"
color: "blue"
runs:
using: "composite"
steps:
- name: Set GitHub Path
run: echo "${{ github.action_path }}/src" >> $GITHUB_PATH
shell: bash
- name: Makes .sql builder
run: |
cd ${{ github.action_path }}/src
gcc -c cargs.c -o cargs.o && gcc main.c cargs.o -o main
cd ${{ github.workspace }}
shell: bash
- name: Runs .sql builder
run: |
args=" --use-transactions --json"
[[ ${{ inputs.strip-html }} == true ]] && args+=" --strip-html"
[[ ${{ inputs.strip-jsx }} == true ]] && args+=" --strip-jsx"
[[ ${{ inputs.strip-md-titles }} == true ]] && args+=" --strip-md-titles"
[[ ${{ inputs.use-front-matter }} == true ]] && args+=" --use-front-matter"
[[ ${{ inputs.path-using-slug }} == true ]] && args+=" --path-using-slug"
echo $(main --input=${{ inputs.path }} --output=search.sql --base-url=${{ inputs.base-url }} $args)
shell: bash
- name: Executes the .sql on SQLite Cloud
run: |
if [[ "${{ inputs.project-string }}" =~ ^sqlitecloud:// ]]; then
[[ "${{ inputs.database }}" ]] || { echo "database input is empty" ; exit 1; }
echo "{ \"sql\": \"" > up.json
cat search.sql >> up.json
echo "\", \"database\": \"${{ inputs.database }}\"}" >> up.json
URL="https:"$(echo ${{ inputs.project-string }} | awk -F ':' '{print $2}')":443/v2/weblite/sql"
RES=$(curl --compressed $URL -H 'Content-Type: application/json' -H 'Authorization: Bearer ${{ inputs.project-string }}' -H 'accept: application/json' -d @up.json)
echo $RES
if [[ "$RES" =~ error ]]; then
echo "Error on SQLite Cloud .sql execution"
exit 1
fi
else
echo "${{ inputs.project-string }} incorrect project string"
exit 1
fi
shell: bash