Skip to content

Commit

Permalink
feat: Add override config boolean to the Github action config (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
damcou committed Jun 30, 2021
1 parent 38961c9 commit c28306e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/github_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ jobs:
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
site-url: 'https://community.algolia.com/algoliasearch-crawler-github-actions/public/github-pages/'
override-config: true
2 changes: 2 additions & 0 deletions .github/workflows/netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
site-url: 'https://deploy-preview-${{ github.event.pull_request.number }}--algolia-ga-actions-netlify.netlify.app/'
override-config: true
- name: Netlify-MAIN => Algolia crawler creation and recrawl (Push on Main branch)
if: github.ref == 'refs/heads/main'
uses: ./
Expand All @@ -45,4 +46,5 @@ jobs:
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
site-url: 'https://algolia-ga-actions-netlify.netlify.app/'
override-config: true

1 change: 1 addition & 0 deletions .github/workflows/vercel_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ jobs:
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
site-url: ${{ steps.deployment.outputs.deployment }}
override-config: true
1 change: 1 addition & 0 deletions .github/workflows/vercel_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ jobs:
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
site-url: 'https://algoliasearch-crawler-github-actions.vercel.app/'
override-config: true
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
site-url:
description: 'url of the site to crawl'
required: true
override-config:
description: 'Override config in case the crawler is already existing'
required: false
default: false

runs:
using: 'node12'
Expand Down
2 changes: 1 addition & 1 deletion public/netlify/1.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</head>
<body>
<h2>First test page</h2>
<p>This is the contents of the first test page.</p>
<p>This is the contents of the first test page</p>
</body>
</html>
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const CRAWLER_NAME = core.getInput('crawler-name').replace(/\//g, '-');
const ALGOLIA_APP_ID = core.getInput('algolia-app-id');
const ALGOLIA_API_KEY = core.getInput('algolia-api-key');
const SITE_URL = core.getInput('site-url');
const OVERRIDE_CONFIG = core.getInput('override-config');

const client = new CrawlerApiClient({
crawlerApiBaseUrl: CRAWLER_API_BASE_URL,
Expand Down Expand Up @@ -79,8 +80,10 @@ async function crawlerReindex(): Promise<void> {
if (filteredCrawlers.length !== 0) {
// If the crawler exists : update it
crawlerId = filteredCrawlers[0].id;
const config = getConfig();
await client.updateConfig(crawlerId, config);
if (OVERRIDE_CONFIG) {
const config = getConfig();
await client.updateConfig(crawlerId, config);
}
} else {
// If it doesn't exist yet: create it
const crawler = await client.createCrawler(CRAWLER_NAME, getConfig());
Expand Down

1 comment on commit c28306e

@vercel
Copy link

@vercel vercel bot commented on c28306e Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.