zola-check-manager

A Github Action allowing you to manage the zola check results in github
git clone git://archive.git.mtrnord.blog/MTRNord/zola-check-manager.git
Log | Files | Refs | README | LICENSE

commit d0b1d53e96ed3be09993e59745c33e60c85f43bc
parent a0b50e7c21e0e4eea83cf248fe4a29a70fcafba8
Author: MTRNord <mtrnord1@gmail.com>
Date:   Tue, 11 Apr 2023 23:09:03 +0200

Fixup the github auth

Diffstat:
M.github/workflows/test.yml | 1+
Maction.yml | 3+++
Msrc/main.ts | 24++++++++++++------------
3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml @@ -22,3 +22,4 @@ jobs: - uses: ./ with: working_directory: ./test_page + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml @@ -14,6 +14,9 @@ inputs: required: false description: "The level of the annotation. Can be one of `notice`, `failure`, `warning`" default: "warning" + repo-token: + required: true + description: "The github token to use. Usually this is `{{ secrets.GITHUB_TOKEN }}`" runs: using: "node16" main: "dist/index.js" diff --git a/src/main.ts b/src/main.ts @@ -1,10 +1,10 @@ -import {addPath, debug, getInput, setFailed, summary} from '@actions/core'; -import {ExecOptions, exec} from '@actions/exec'; -import {getOctokit, context} from '@actions/github'; -import {which} from '@actions/io'; -import {cacheDir, downloadTool, extractTar, find} from '@actions/tool-cache'; -import {readFile} from 'fs/promises'; -import {Grammar, Parser} from 'nearley'; +import { addPath, debug, getInput, setFailed, summary } from '@actions/core'; +import { ExecOptions, exec } from '@actions/exec'; +import { getOctokit, context } from '@actions/github'; +import { which } from '@actions/io'; +import { cacheDir, downloadTool, extractTar, find } from '@actions/tool-cache'; +import { readFile } from 'fs/promises'; +import { Grammar, Parser } from 'nearley'; import path from 'path'; import grammar from './grammar.js'; // eslint-disable-next-line import/no-named-as-default -- False positive @@ -82,7 +82,7 @@ async function run(): Promise<void> { try { parser.feed(dataString); } catch (parseError: unknown) { - setFailed(`Error at character ${(parseError as {offset: string}).offset}`); + setFailed(`Error at character ${(parseError as { offset: string }).offset}`); } const annotations: { @@ -144,7 +144,7 @@ async function run(): Promise<void> { } } - const token = process.env['GITHUB_TOKEN'] || ''; + const token = getInput("repo-token"); const octokit = getOctokit(token); // call octokit to create a check with annotation and details @@ -174,9 +174,9 @@ async function run(): Promise<void> { // TODO: Get stats from zola stdOut .addTable([ [ - {data: 'Link Type', header: true}, - {data: 'Total', header: true}, - {data: 'Result', header: true} + { data: 'Link Type', header: true }, + { data: 'Total', header: true }, + { data: 'Result', header: true } ], ['Internal', totalInternal, 'Pass ✅'], ['External', totalExternal, `Fail (${errorCount} error(s) found) ❌`]