diff --git a/.github/workflows/next.yml b/.github/workflows/next.yml index 7661cee..7e4689f 100644 --- a/.github/workflows/next.yml +++ b/.github/workflows/next.yml @@ -23,7 +23,7 @@ jobs: run: npm install --global vercel@latest - run: rm -rf .vercel - name: Pull Vercel Environment Information - run: vercel pull --yes --git-branch=release/1.0 --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + run: vercel pull --yes --git-branch=main --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - name: Build Project Artifacts run: BASE_URL=https://next.renative.org ALGOLIA_INDEX=renative_docsearch vercel build - name: Deploy Project Artifacts to Vercel diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml new file mode 100644 index 0000000..0bc264c --- /dev/null +++ b/.github/workflows/prod.yml @@ -0,0 +1,38 @@ +name: Vercel Prod Deployment + +on: + push: + branches: + - release + +jobs: + release: + runs-on: ubuntu-latest + environment: vercel-deployments + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '18.x' + - name: Set scraper config environment variable + id: scraper_config + run: | + export SCRAPER_CONFIG=$(cat ./config.prod.json | jq -r tostring) + echo "scraper_config=${SCRAPER_CONFIG}" >> $GITHUB_OUTPUT + - name: Install Vercel CLI + run: npm install --global vercel@latest + - run: rm -rf .vercel + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: BASE_URL=https://renative.org ALGOLIA_INDEX=renative_docsearch vercel build + - name: Deploy Project Artifacts to Vercel + run: | + url="$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" + vercel alias --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_ORG_ID }} set "$url" renative.org + - name: Update Algolia index + uses: addnab/docker-run-action@v3 + with: + image: algolia/docsearch-scraper + run: | + CONFIG='${{ steps.scraper_config.outputs.scraper_config }}' APPLICATION_ID=${{ secrets.ALGOLIA_APPLICATION_ID }} API_KEY=${{ secrets.ALGOLIA_API_KEY }} pipenv run python -m src.index diff --git a/config.next.json b/config.next.json index 332da62..b3c754d 100644 --- a/config.next.json +++ b/config.next.json @@ -1,8 +1,6 @@ { "index_name": "renative_docsearch", - "sitemap_urls": [ - "https://next.renative.org/sitemap.xml" - ], + "sitemap_urls": ["https://next.renative.org/sitemap.xml"], "selectors": { "lvl0": { "selector": "header h1, article h1", @@ -46,21 +44,7 @@ "unordered(content)", "unordered(anchor)" ], - "attributesToRetrieve": [ - "hierarchy", - "content", - "anchor", - "url", - "url_without_anchor", - "type" - ], - "ranking": [ - "words", - "filters", - "typo", - "exact", - "attribute", - "proximity" - ] + "attributesToRetrieve": ["hierarchy", "content", "anchor", "url", "url_without_anchor", "type"], + "ranking": ["words", "filters", "typo", "exact", "attribute", "proximity"] } -} \ No newline at end of file +} diff --git a/config.prod.json b/config.prod.json new file mode 100644 index 0000000..15706b6 --- /dev/null +++ b/config.prod.json @@ -0,0 +1,50 @@ +{ + "index_name": "renative_docsearch", + "sitemap_urls": ["https://renative.org/sitemap.xml"], + "selectors": { + "lvl0": { + "selector": "header h1, article h1", + "global": true, + "default_value": "Documentation" + }, + "lvl1": "article h2", + "lvl2": "article h3", + "lvl3": "article h4", + "lvl4": "article h5, article td:first-child", + "lvl5": "article h6", + "content": "article p, article li, article td:last-child" + }, + "strip_chars": " .,;:#", + "custom_settings": { + "searchableAttributes": [ + "unordered(hierarchy.lvl0)", + "unordered(hierarchy_radio.lvl0)", + "unordered(hierarchy_camel.lvl0)", + "unordered(hierarchy_radio_camel.lvl0)", + "unordered(hierarchy.lvl1)", + "unordered(hierarchy_radio.lvl1)", + "unordered(hierarchy_camel.lvl1)", + "unordered(hierarchy_radio_camel.lvl1)", + "unordered(hierarchy.lvl2)", + "unordered(hierarchy_radio.lvl2)", + "unordered(hierarchy_camel.lvl2)", + "unordered(hierarchy_radio_camel.lvl2)", + "unordered(hierarchy.lvl3)", + "unordered(hierarchy_radio.lvl3)", + "unordered(hierarchy_camel.lvl3)", + "unordered(hierarchy_radio_camel.lvl3)", + "unordered(hierarchy.lvl4)", + "unordered(hierarchy_radio.lvl4)", + "unordered(hierarchy_camel.lvl4)", + "unordered(hierarchy_radio_camel.lvl4)", + "unordered(hierarchy.lvl5)", + "unordered(hierarchy_radio.lvl5)", + "unordered(hierarchy_camel.lvl5)", + "unordered(hierarchy_radio_camel.lvl5)", + "unordered(content)", + "unordered(anchor)" + ], + "attributesToRetrieve": ["hierarchy", "content", "anchor", "url", "url_without_anchor", "type"], + "ranking": ["words", "filters", "typo", "exact", "attribute", "proximity"] + } +}