diff --git a/.github/workflows/aloglia.yml b/.github/workflows/aloglia.yml index 6830e11e..86728323 100644 --- a/.github/workflows/aloglia.yml +++ b/.github/workflows/aloglia.yml @@ -1,22 +1,46 @@ +name: Netlify -> Algolia Crawler +on: + push: + branches: [ master ] + pull_request: + types: ['opened', 'edited', 'reopened', 'synchronize'] -# name: Algolia Upload Records -# on: -# [push] #推送时执行 -# jobs: -# algolia: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - name: Get the content of algolia.json as config -# id: algolia_config -# run: echo "::set-output name=config::$(cat algolia.json | jq -r tostring)" -# - name: Algolia Crawler Automatic Crawl -# uses: algolia/algoliasearch-crawler-github-actions@v1.1.0 -# id: algolia_crawler -# with: # mandatory parameters -# crawler-user-id: ${{ secrets.CRAWLER_USER_ID }} -# crawler-api-key: ${{ secrets.CRAWLER_API_KEY }} -# algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }} -# algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }} -# site-url: 'https://wot-design-uni.netlify.app' - +jobs: + algolia_recrawl: + name: Algolia Recrawl + runs-on: ubuntu-latest + steps: + # checkout this repo + - name: Checkout Repo + uses: actions/checkout@v2 + + # We don't know when the site will be deployed, we just wait a few seconds + # Better solutions can be found + - name: Sleep for 30s + run: sleep 30 + + # For PRs + - name: Netlify-PR => Algolia crawler creation and recrawl on preview (Pull Request) + if: github.ref != 'refs/heads/master' + uses: algolia/algoliasearch-crawler-github-actions@v1 + id: crawler_pr + with: + crawler-user-id: ${{ secrets.CRAWLER_USER_ID }} + crawler-api-key: ${{ secrets.CRAWLER_API_KEY }} + algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }} + algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }} + site-url: 'https://deploy-preview-${{ github.event.pull_request.number }}--wot-design-uni.netlify.app/' + override-config: true + + # For main branch + - name: Netlify-MAIN => Algolia crawler creation and recrawl (Push on Main branch) + if: github.ref == 'refs/heads/master' + uses: algolia/algoliasearch-crawler-github-actions@v1 + id: crawler_push + with: + crawler-user-id: ${{ secrets.CRAWLER_USER_ID }} + crawler-api-key: ${{ secrets.CRAWLER_API_KEY }} + algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }} + algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }} + site-url: 'https://wot-design-uni.netlify.app/' + override-config: true