reuixiy / hugo-theme-meme

😝 You can’t spell awesome without MemE!
https://io-oi.me/hugo-theme-meme
MIT License
1.01k stars 279 forks source link

Do we have to upload Algolia manually? #419

Closed Acytoo closed 1 year ago

Acytoo commented 1 year ago

Hi, do we have to upload the generated Algolia JSON manually? Can we use some APIs to upload the JSON automatically after each time we build the site?

I found the comment about Algolia really confusing, what is algoliaIndexName?

Rurouni-z commented 1 year ago
name: Deploy Hugo Site to Github Pages

on:
  push:
    branches:
      - main

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: "latest"
          extended: true

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # 这里的 ACTIONS_DEPLOY_KEY 则是secrets中设置Private Key的变量名
          external_repository: xxxx/xxxx.github.io # Pages 远程仓库 
          publish_dir: ./public
          keep_files: false # remove existing files
          publish_branch: build  # deploying branch
          commit_message: ${{ github.event.head_commit.message }}

      - name: Upload Algolia
        uses: iChochy/Algolia-Upload-Records@main
        # 设置环境变量利用secrets
        env:
          APPLICATION_ID: ${{secrets.APPLICATION_ID}}
          ADMIN_API_KEY: ${{secrets.ADMIN_API_KEY}}
          INDEX_NAME: ${{secrets.INDEX_NAME}}
          FILE_PATH: ${{secrets.FILE_PATH}}  # ./public/algolia.json

使用 GitHub Actions 自动上传搜索记录到 AlgoliaHugo + GitHub Action,搭建你的博客自动发布系统