generated from Bullrich/parity-action-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added summary to action and fixed exit error (#17)
- Added a nice summary that is shown after every run. - Made exiting of application conditional on the state. - With the finally it would always exit as successful even if it failed. - Now it sets an error code when valid. - Implemented action on itself. - Now it will run after each push.
- Loading branch information
Showing
2 changed files
with
50 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |