Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich job summary #341

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 18 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as github from '@actions/github'
import * as Webhooks from '@octokit/webhooks-types'
import * as fs from 'fs'
import * as YAML from 'yaml'
import {EOL} from 'os'
import {Settings, ReviewGatekeeper} from './review-gatekeeper'

async function run(): Promise<void> {
Expand Down Expand Up @@ -53,22 +52,28 @@ async function run(): Promise<void> {
const sha = payload.pull_request.head.sha
// The workflow url can be obtained by combining several environment varialbes, as described below:
// https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
const workflow_url = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}/actions/runs/${process.env['GITHUB_RUN_ID']}`
core.info(`Setting a status on commit (${sha})`)

octokit.rest.repos.createCommitStatus({
...context.repo,
sha,
state: review_gatekeeper.satisfy() ? 'success' : 'failure',
context: 'PR Gatekeeper Status',
target_url: workflow_url,
description: review_gatekeeper.satisfy()
? undefined
: review_gatekeeper.getMessages().join(' ').substr(0, 140)
})
core.summary
.addTable([
[
{data: 'Group', header: true},
{data: 'Approval status', header: true},
{data: 'Approver', header: true},
{data: 'Eligible approvers', header: true}
],
[
'application-development',
':white_check_mark: Complete',
'yuichielectric',
'yuichielectric, mohan-the-octocat'
],
['security-team', ':hourglass_flowing_sand: Pending', '', 'rohitnb']
])
.write()

if (!review_gatekeeper.satisfy()) {
core.setFailed(review_gatekeeper.getMessages().join(EOL))
core.setFailed('failed')
return
}
} catch (error) {
Expand Down