* Build(deps-dev): bump eslint-plugin-import from 2.20.1 to 2.20.2 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.20.1 to 2.20.2. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.20.1...v2.20.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Fixes * refactor: combine imports * refactor: combine imports * refactor: combine imports * refactor: update import ordering Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> Co-authored-by: Paul Melnikow <email@paulmelnikow.com> Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com> Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
89 lines
2.1 KiB
JavaScript
89 lines
2.1 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('@hapi/joi')
|
|
const { isBuildStatus, renderBuildStatusBadge } = require('../build-status')
|
|
const { BaseSvgScrapingService } = require('..')
|
|
const { documentation } = require('./github-helpers')
|
|
|
|
const schema = Joi.object({
|
|
message: Joi.alternatives()
|
|
.try(isBuildStatus, Joi.equal('no status'))
|
|
.required(),
|
|
}).required()
|
|
|
|
const keywords = ['action', 'actions']
|
|
|
|
module.exports = class GithubWorkflowStatus extends BaseSvgScrapingService {
|
|
static get category() {
|
|
return 'build'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'github/workflow/status',
|
|
pattern: ':user/:repo/:workflow/:branch*',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'GitHub Workflow Status',
|
|
pattern: ':user/:repo/:workflow',
|
|
namedParams: {
|
|
user: 'actions',
|
|
repo: 'toolkit',
|
|
workflow: 'Main workflow',
|
|
},
|
|
staticPreview: renderBuildStatusBadge({
|
|
status: 'passing',
|
|
}),
|
|
documentation,
|
|
keywords,
|
|
},
|
|
{
|
|
title: 'GitHub Workflow Status (branch)',
|
|
pattern: ':user/:repo/:workflow/:branch',
|
|
namedParams: {
|
|
user: 'actions',
|
|
repo: 'toolkit',
|
|
workflow: 'Main workflow',
|
|
branch: 'master',
|
|
},
|
|
staticPreview: renderBuildStatusBadge({
|
|
status: 'passing',
|
|
}),
|
|
documentation,
|
|
keywords,
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return {
|
|
label: 'build',
|
|
}
|
|
}
|
|
|
|
async fetch({ user, repo, workflow, branch }) {
|
|
const { message: status } = await this._requestSvg({
|
|
schema,
|
|
url: `https://github.com/${user}/${repo}/workflows/${encodeURIComponent(
|
|
workflow
|
|
)}/badge.svg`,
|
|
options: { qs: { branch } },
|
|
valueMatcher: />([^<>]+)<\/tspan><\/text><\/g><path/,
|
|
errorMessages: {
|
|
404: 'repo, branch, or workflow not found',
|
|
},
|
|
})
|
|
|
|
return { status }
|
|
}
|
|
|
|
async handle({ user, repo, workflow, branch }) {
|
|
const { status } = await this.fetch({ user, repo, workflow, branch })
|
|
return renderBuildStatusBadge({ status })
|
|
}
|
|
}
|