Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/clear-cahce.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
29 changes: 29 additions & 0 deletions scripts/clear-readme-cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const response = await fetch("https://github.com/myty/dispatch-queue");
const body = await response.text();

const queue = body
.split("<img ")
.map((line) => {
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);
}
});
}),
);