diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c20995b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: tests +on: + push: + paths: + - .github/workflows/test.yml + - __tests__/*.ts + - src/*.ts + - package.json + - package-lock.json +jobs: + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "20" + - run: npm ci + - run: npm test + build-and-run-action: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "20" + - run: npm ci + - run: npm run build + - uses: ./ + id: run-action + with: + script: examples/script.js + - run: 'echo "${{ steps.run-action.outputs.output }}" | jq' diff --git a/examples/script.js b/examples/script.js new file mode 100644 index 0000000..b7dd1b2 --- /dev/null +++ b/examples/script.js @@ -0,0 +1,18 @@ +// A sample flyscrape script. + +export const config = { + url: "https://example.com", +}; + +export default function ({ doc, _ }) { + const links = doc.find("a"); + + return { + urls: links.map((link) => { + return { + name: link.text(), + url: link.attr("href"), + }; + }), + }; +}