diff --git a/.github/workflows/get-fellows.yml b/.github/workflows/get-fellows.yml new file mode 100644 index 0000000..607c631 --- /dev/null +++ b/.github/workflows/get-fellows.yml @@ -0,0 +1,19 @@ +name: Mention fellows + +on: + push: + branches: + - main + +jobs: + mention-fellows: + runs-on: ubuntu-latest + steps: + - uses: paritytech/get-fellows-action@main + id: fellows + - name: Mention them + run: | + echo "The fellows are $FELLOWS" + env: + # the handles of the fellows separated by commas + FELLOWS: ${{ steps.fellows.outputs.github-handles }}" diff --git a/src/index.ts b/src/index.ts index d9b316c..e155349 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,24 +1,46 @@ -import { setFailed, setOutput } from "@actions/core"; +import { setFailed, setOutput, summary } from "@actions/core"; +import { SummaryTableRow } from "@actions/core/lib/summary"; import { FellowObject, fetchAllFellows } from "./fellows"; import { generateCoreLogger } from "./util"; const logger = generateCoreLogger(); -const mapFellows = (fellows: FellowObject[]) => { +const mapFellows = async (fellows: FellowObject[]) => { setOutput("fellows", JSON.stringify(fellows)); const githubHandles = fellows - .map((f) => f.githubHandle) - .filter((f) => !!f) + .map(({ githubHandle }) => githubHandle) + .filter((handle) => !!handle) .join(","); setOutput("github-handles", githubHandles); + + const table: SummaryTableRow[] = [ + [ + { header: true, data: "Rank" }, + { header: true, data: "GitHub Handle" }, + { header: true, data: "Address" }, + ], + ]; + + for (const fellow of fellows.sort((old, { rank }) => rank - old.rank)) { + if (fellow.githubHandle) { + table.push([ + fellow.rank.toString(), + `@${fellow.githubHandle}`, + fellow.address, + ]); + } + } + + await summary.addHeading("Fellows").addTable(table).write(); + + // TODO: Remove this once https://github.com/polkadot-api/polkadot-api/issues/327 is fixed + process.exit(0); }; fetchAllFellows(logger) .then(mapFellows) - .catch(setFailed) - .finally(() => { - logger.info("Shutting down application"); - // TODO: Remove this once https://github.com/polkadot-api/polkadot-api/issues/327 is fixed - process.exit(0); + .catch((err) => { + setFailed(err as Error); + process.exit(1); });