Skip to content

Commit c97bc4d

Browse files
committedApr 13, 2023
Update action
1 parent 6d14320 commit c97bc4d

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed
 

‎.github/workflows/crawl.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Get all URLs and begin crawling
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
47
push:
58
branches:
69
- main
@@ -12,12 +15,9 @@ jobs:
1215
runs-on: ubuntu-latest
1316
steps:
1417
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
1519
- name: Run script
16-
uses: tj-actions/puppeteer@v4
17-
id: puppeteer
18-
with:
19-
files: |
20-
.github/workflows/crawl.js
20+
run: npm run crawl
2121
env:
2222
ALGOLIA_CRAWLER_API_KEY: ${{secrets.ALGOLIA_CRAWLER_API_KEY}}
2323
ALGOLIA_CRAWLER_ID: ${{secrets.ALGOLIA_CRAWLER_ID}}

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
package-lock.json

‎.github/workflows/crawl.js ‎crawl.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const fetch = require('node-fetch');
21
const puppeteer = require('puppeteer');
32

43
(async () => {
@@ -9,6 +8,11 @@ const puppeteer = require('puppeteer');
98
apiKey: process.env.ALGOLIA_CRAWLER_API_KEY,
109
}
1110

11+
if (!crawler.url || !crawler.id || !crawler.userId || !crawler.apiKey) {
12+
console.log("Missing required env vars")
13+
return
14+
}
15+
1216
const updateUrls = async (urls) => {
1317
const updateResponse = await fetch(`${crawler.url}/${crawler.id}/config`, {
1418
method: "PATCH",

‎package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "api-schemas",
3+
"version": "1.0.0",
4+
"description": "This repository contains OpenAPI schemas for the Cloudflare API.",
5+
"main": "index.js",
6+
"scripts": {
7+
"crawl": "node crawl.js",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"puppeteer": "^19.9.0"
15+
}
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.