blob: 87a881df4efe6d4a9f0b6cc74ec3c876a582d3dc (
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
36
37
38
|
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '../libs/features';
import {getRepoURL, getRepoPath} from '../libs/utils';
const isWorkflowFile = (): boolean => pageDetect.isSingleFile() && /\/\.github\/workflows\/.+\.ya?ml$/.test(getRepoPath()!);
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(`${location.origin}/${getRepoURL()}/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>
);
}
features.add({
id: __filebasename,
description: 'Adds a link to access the past runs of a GitHub Action workflow when seeing the workflow configuration file.',
screenshot: 'https://user-images.githubusercontent.com/1402241/80146153-ab6d6400-85b1-11ea-9f38-e87950692a62.png'
}, {
include: [
isWorkflowFile
],
init
});
|