From 0dd50f8c2e9ccb33a78d395308d033fde9424d8d Mon Sep 17 00:00:00 2001 From: Michael Tyson Date: Sun, 2 Oct 2022 10:25:05 -0400 Subject: [PATCH] update README and publish GH action --- .github/workflows/clear-cahce.yml | 18 ++++++++++++++++ .github/workflows/publish.yml | 36 +++++++++++++++++++++++++++++++ README.md | 4 ++++ scripts/clear-readme-cache.ts | 29 +++++++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 .github/workflows/clear-cahce.yml create mode 100644 .github/workflows/publish.yml create mode 100644 scripts/clear-readme-cache.ts diff --git a/.github/workflows/clear-cahce.yml b/.github/workflows/clear-cahce.yml new file mode 100644 index 0000000..3717837 --- /dev/null +++ b/.github/workflows/clear-cahce.yml @@ -0,0 +1,18 @@ +name: Clear README Cache + +on: + workflow_dispatch: + +jobs: + clear-cache: + name: Clear README Image Cache + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: denoland/setup-deno@v1.1.0 + with: + deno-version: v1.x # Run with latest stable Deno. + + - name: Clear README Image Cache + run: deno run --unstable --allow-net ./scripts/clear-readme-cache.ts \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ce21a75 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish +on: + release: + types: [published] + +jobs: + publish: + name: Publishing + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: denoland/setup-deno@v1.1.0 + with: + deno-version: v1.x # Run with latest stable Deno. + + - name: Check format + run: deno fmt --check + + - name: Run Linter + run: deno lint + + - name: Run Tests + run: deno test --allow-all --coverage=cov/ + + - name: Generate coverage report + run: deno coverage --lcov cov > cov.lcov + + - name: Upload coverage to Coveralls.io + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} # Generated by GitHub. + path-to-lcov: cov.lcov + + - name: Clear README Image Cache + run: deno run --unstable --allow-net ./scripts/clear-readme-cache.ts \ No newline at end of file diff --git a/README.md b/README.md index 9241b3f..dd27db4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # DispatchQueue +[![GitHub version](https://badgen.net/github/release/myty/dispatch-queue?color=green)](https://github.com/myty/dispatch-queue) +[![deno land](https://badgen.net/github/release/myty/dispatch-queue?color=green&label=deno.land)](https://deno.land/x/dispatch_queue) +[![Coverage Status](https://badgen.net/coveralls/c/github/myty/dispatch-queue?color=green)](https://coveralls.io/github/myty/dispatch-queue?branch=main) + A deno and npm dispatch queue with the ability to configure multiple queue processors. diff --git a/scripts/clear-readme-cache.ts b/scripts/clear-readme-cache.ts new file mode 100644 index 0000000..c187b53 --- /dev/null +++ b/scripts/clear-readme-cache.ts @@ -0,0 +1,29 @@ +const response = await fetch("https://github.com/myty/dispatch-queue"); +const body = await response.text(); + +const queue = body + .split(" { + const match = line.match( + /^src="(https:\/\/camo\.githubusercontent\.com\/[a-f0-9]+\/[a-f0-9]+)" alt="([^"]+)"/, + ); + if (match) { + return { url: match[1], alt: match[2] }; + } + }) + .filter( + (line): line is { url: RegExpMatchArray[0]; alt: RegExpMatchArray[1] } => + !!line, + ); + +Promise.allSettled( + queue.map((obj) => { + return fetch(obj.url, { method: "PURGE" }) + .then(() => console.log("PURGE", obj.alt)) + .catch((error) => { + if (error) { + console.error("Error: PURGE", obj.alt, error); + } + }); + }), +);