This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build website and deploy to Github Pages | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy: | |
name: Deploy to GitHub Pages | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
APPLICATION_ID: ${{secrets.APPLICATION_ID}} | |
API_KEY: ${{secrets.API_KEY}} | |
INDEX_NAME: ${{secrets.INDEX_NAME}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: npm | |
- name: Install dependencies | |
run: npm install | |
- name: Create .env file | |
uses: ozaytsev86/create-env-file@v1 | |
with: | |
ENV_APPLICATION_ID: ${{secrets.APPLICATION_ID}} | |
ENV_API_KEY: ${{secrets.API_KEY}} | |
ENV_INDEX_NAME: ${{secrets.INDEX_NAME}} | |
- name: Build website | |
run: npm run build | |
- name: Create .nojekyll file for GitHub Pages | |
run: | | |
mkdir -p build/test-site/ && touch -f build/test-site/.nojekyll | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{secrets.GITHUB_TOKEN}} | |
publish_dir: ./build | |
user_name: liuyuweitarek | |
user_email: [email protected] | |
- name: Get the content of algolia.json as config | |
id: algolia_config | |
run: echo "config=$(cat ./algolia/prod-algolia-config.json | jq -r tostring)" >> $GITHUB_OUTPUT | |
- name: Push indices to Algolia | |
uses: signcl/docsearch-scraper-action@master | |
env: | |
INDEX_NAME: ${{secrets.INDEX_NAME}} | |
APPLICATION_ID: ${{secrets.APPLICATION_ID}} | |
API_KEY: ${{secrets.API_KEY}} | |
CONFIG: ${{ steps.algolia_config.outputs.config }} |