blob: f0bde5a36c79b75491f4d345a7bc0973a84ec194 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '.';
import {buildRepoURL, getRepo} from '../github-helpers';
const isWorkflowFile = (): boolean => pageDetect.isSingleFile() && /\/\.github\/workflows\/.+\.ya?ml$/.test(getRepo()!.path);
function init(): void {
const actionName = select.all('.blob-code-inner')
.find(line => line.textContent!.startsWith('name'))!
.textContent!
.replace(/^name:\s+/, '')
.replace(/["']/g, '')
.trim();
const actionURL = new URL(buildRepoURL('actions'));
actionURL.searchParams.set('query', `workflow:"${actionName}"`);
select('#raw-url')!
.parentElement! // `BtnGroup`
.prepend(
<a className="btn btn-sm BtnGroup-item" href={String(actionURL)}>
Past runs
</a>
);
}
void features.add(__filebasename, {
include: [
isWorkflowFile
],
init
});
|