Skip to content

Commit 060c0c8

Browse files
committed
new action inputs!
1 parent b660f71 commit 060c0c8

8 files changed

Lines changed: 1036 additions & 140 deletions

File tree

.github/workflows/test.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v4
12+
- name: Clone the SQLite Cloud docs repository
13+
run: git clone https://github.com/sqlitecloud/docs
14+
shell: bash
1215
- uses: ./
1316
with:
1417
project-string: ${{ secrets.PROJECT_STRING }}
1518
database: documentation.sqlite
16-
remove-astro-headers: true
17-
remove-titles: true
19+
strip-astro-header: true
20+
strip-md-titles: true
21+
strip-jsx: true
22+
strip-html: true
23+
path: docs

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ jobs:
4141
4242
3. Make sure you have a project on SQLite Cloud. If not, sign up for an account and create one.
4343
4. Add the Project Connection String as a secret in your repository settings, named `PROJECT_STRING`.
44-
5. Customize the `database` and `path` according to your needs.
45-
* `remove-astro-headers`: Set this input to `true` if you want to remove the Astro headers from your documentation files before building the SQLite Cloud documentation table.
46-
* `remove-titles`: Set this input to `true` if you want to remove the titles from your documentation files before building the SQLite Cloud documentation table.
44+
5. Customize these inputs according to your needs.
45+
* if the `database` input doesn't exist on the SQLite Cloud project the workflow will create it automatically.
4746
* if the `path` input isn't specified the workflow will search for every .md or .mdx file recursively from the root folder.
47+
* `strip-html`: Set this input to `true` if you want to remove the html elements.
48+
* `strip-jsx`: Set this input to `true` if you want to remove the jsx elements.
49+
* `strip-md-titles`: Set this input to `true` if you want to remove the markdown titles to avoid redundancy in the search.
50+
* `strip-astro-header`: Set this input to `true` if you want to remove the Astro header from every file.
4851
6. Commit and push the workflow file to your repository.
4952

5053

action.yml

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ inputs:
1313
description: The path of the markdown files, by default it will parse every .md/.mdx file recursively starting from the working directory.
1414
required: false
1515
default: $(pwd)
16-
remove-astro-headers:
17-
description: If you use Astro and you want to remove its docs header make this true.
16+
strip-html:
17+
description: If you want to remove html elements from the search set this to true.
18+
required: false
19+
default: false
20+
strip-jsx:
21+
description: If you want to remove jsx elements from the search set this to true.
22+
required: false
23+
default: false
24+
strip-md-titles:
25+
description: If you want to avoid redundancy of your markdown titles in the search set this to true.
1826
required: false
1927
default: false
20-
remove-titles:
21-
description: If you want to avoid redundancy of your titles in the search set this to true.
28+
strip-astro-header:
29+
description: If you use Astro and you want to remove its docs header make this true.
2230
required: false
2331
default: false
2432

@@ -30,30 +38,44 @@ runs:
3038
using: "composite"
3139
steps:
3240

33-
- name: Checks out the action repository
34-
uses: actions/checkout@v4
35-
with:
36-
clean: false
37-
path: sqlitecloud-docsearch
41+
- name: Set GitHub Path
42+
run: echo "${{ github.action_path }}/src" >> $GITHUB_PATH
43+
shell: bash
3844

39-
- name: Builds the docBuilder
40-
run: make sqlitecloud-docsearch/main
45+
- name: Makes .sql builder
46+
run: |
47+
cd ${{ github.action_path }}/src
48+
gcc -c cargs.c -o cargs.o && gcc main.c cargs.o -o main
49+
cd ${{ github.workspace }}
4150
shell: bash
4251

43-
- name: Runs the docBuilder
44-
run: ./sqlitecloud-docsearch/main ${{ inputs.path }} search.sql ${{ inputs.remove-astro-headers }} ${{ inputs.remove-titles }}
52+
- name: Runs .sql builder
53+
run: |
54+
args="--add-create-database --use-transactions --json"
55+
[[ ${{ inputs.strip-html }} == true ]] && args+=" --strip-html"
56+
[[ ${{ inputs.strip-jsx }} == true ]] && args+=" --strip-jsx"
57+
[[ ${{ inputs.strip-md-titles }} == true ]] && args+=" --strip-md-titles"
58+
[[ ${{ inputs.strip-astro-header }} == true ]] && args+=" --strip-astro-header"
59+
echo $(main --input=${{ inputs.path }} --output=search.sql $args)
4560
shell: bash
4661

47-
- name: Executes the SQL query
62+
- name: Executes the .sql on SQLite Cloud
4863
run: |
4964
if [[ "${{ inputs.project-string }}" =~ ^sqlitecloud:// ]]; then
5065
[[ "${{ inputs.database }}" ]] || { echo "database input is empty" ; exit 1; }
51-
SQL=$(echo -e $(cat sqlitecloud-docsearch/search.sql))
52-
BODY="{ \"sql\": \"${SQL}\", \"database\": \"${{ inputs.database }}\"}"
66+
echo -e -n "{ \"sql\": \"" > up.json
67+
cat search.sql >> up.json
68+
echo -e "\", \"database\": \"${{ inputs.database }}\"}" >> up.json
69+
cat up.json
5370
URL="https:"$(echo ${{ inputs.project-string }} | awk -F ':' '{print $2}')":8090/v2/weblite/sql"
54-
echo $(curl $URL -H 'Content-Type: application/json' -H 'Authorization: Bearer ${{ inputs.project-string }}' -H 'accept: application/json' -d "$BODY")
71+
RES=$(curl $URL -H 'Content-Type: application/json' -H 'Authorization: Bearer ${{ inputs.project-string }}' -H 'accept: application/json' -d @up.json)
72+
echo $RES
73+
if [[ "$RES" =~ error ]]; then
74+
echo "Error on SQLite Cloud .sql execution"
75+
exit 1
76+
fi
5577
else
5678
echo "${{ inputs.project-string }} incorrect project string"
5779
exit 1
5880
fi
59-
shell: bash
81+
shell: bash

0 commit comments

Comments
 (0)