@backstage-community/plugin-github-actions 0.6.16 → 0.6.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +52 -2
- package/alpha/package.json +7 -0
- package/dist/alpha/apis.esm.js +15 -0
- package/dist/alpha/apis.esm.js.map +1 -0
- package/dist/alpha/entityCards.esm.js +51 -0
- package/dist/alpha/entityCards.esm.js.map +1 -0
- package/dist/alpha/entityContent.esm.js +15 -0
- package/dist/alpha/entityContent.esm.js.map +1 -0
- package/dist/alpha.d.ts +10 -0
- package/dist/alpha.esm.js +24 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/api/GithubActionsApi.esm.js +8 -0
- package/dist/api/GithubActionsApi.esm.js.map +1 -0
- package/dist/api/GithubActionsClient.esm.js +113 -0
- package/dist/api/GithubActionsClient.esm.js.map +1 -0
- package/dist/api/types.esm.js +10 -0
- package/dist/api/types.esm.js.map +1 -0
- package/dist/components/Cards/Cards.esm.js +78 -0
- package/dist/components/Cards/Cards.esm.js.map +1 -0
- package/dist/components/Cards/RecentWorkflowRunsCard.esm.js +71 -0
- package/dist/components/Cards/RecentWorkflowRunsCard.esm.js.map +1 -0
- package/dist/components/Cards/index.esm.js +3 -0
- package/dist/components/Cards/index.esm.js.map +1 -0
- package/dist/components/Router.esm.js +28 -0
- package/dist/components/Router.esm.js.map +1 -0
- package/dist/components/WorkflowRunDetails/WorkflowRunDetails.esm.js +128 -0
- package/dist/components/WorkflowRunDetails/WorkflowRunDetails.esm.js.map +1 -0
- package/dist/components/WorkflowRunDetails/useWorkflowRunJobs.esm.js +49 -0
- package/dist/components/WorkflowRunDetails/useWorkflowRunJobs.esm.js.map +1 -0
- package/dist/components/WorkflowRunDetails/useWorkflowRunsDetails.esm.js +27 -0
- package/dist/components/WorkflowRunDetails/useWorkflowRunsDetails.esm.js.map +1 -0
- package/dist/components/WorkflowRunLogs/WorkflowRunLogs.esm.js +106 -0
- package/dist/components/WorkflowRunLogs/WorkflowRunLogs.esm.js.map +1 -0
- package/dist/components/WorkflowRunLogs/useDownloadWorkflowRunLogs.esm.js +26 -0
- package/dist/components/WorkflowRunLogs/useDownloadWorkflowRunLogs.esm.js.map +1 -0
- package/dist/components/WorkflowRunStatus/WorkflowRunStatus.esm.js +61 -0
- package/dist/components/WorkflowRunStatus/WorkflowRunStatus.esm.js.map +1 -0
- package/dist/components/WorkflowRunsCard/WorkflowRunsCard.esm.js +296 -0
- package/dist/components/WorkflowRunsCard/WorkflowRunsCard.esm.js.map +1 -0
- package/dist/components/WorkflowRunsTable/WorkflowRunsTable.esm.js +139 -0
- package/dist/components/WorkflowRunsTable/WorkflowRunsTable.esm.js.map +1 -0
- package/dist/components/getHostnameFromEntity.esm.js +10 -0
- package/dist/components/getHostnameFromEntity.esm.js.map +1 -0
- package/dist/components/getProjectNameFromEntity.esm.js +5 -0
- package/dist/components/getProjectNameFromEntity.esm.js.map +1 -0
- package/dist/components/useWorkflowRuns.esm.js +122 -0
- package/dist/components/useWorkflowRuns.esm.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +8 -1237
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +55 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/routes.esm.js +13 -0
- package/dist/routes.esm.js.map +1 -0
- package/package.json +37 -18
- package/dist/esm/index-CRpdBPJi.esm.js +0 -50
- package/dist/esm/index-CRpdBPJi.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage-community/plugin-github-actions
|
|
2
2
|
|
|
3
|
+
## 0.6.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9c52968: Adds support for Backstage's new frontend system, available via the `/alpha` sub-path export.
|
|
8
|
+
|
|
9
|
+
## 0.6.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 61d5aff: version:bump to v1.29.1
|
|
14
|
+
|
|
3
15
|
## 0.6.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Website: [https://github.com/actions](https://github.com/actions)
|
|
4
4
|
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [GitHub Actions Plugin](#github-actions-plugin)
|
|
8
|
+
- [Table of Contents](#table-of-contents)
|
|
9
|
+
- [Screenshots](#screenshots)
|
|
10
|
+
- [Setup](#setup)
|
|
11
|
+
- [Generic Requirements](#generic-requirements)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Integrating with `EntityPage`](#integrating-with-entitypage)
|
|
14
|
+
- [Integrating with `EntityPage` (New Frontend System)](#integrating-with-entitypage-new-frontend-system)
|
|
15
|
+
- [Self-hosted / Enterprise GitHub](#self-hosted--enterprise-github)
|
|
16
|
+
- [Features](#features)
|
|
17
|
+
- [Limitations](#limitations)
|
|
18
|
+
- [Optional Workflow Runs Card View](#optional-workflow-runs-card-view)
|
|
19
|
+
|
|
5
20
|
## Screenshots
|
|
6
21
|
|
|
7
22
|
TBD
|
|
@@ -33,7 +48,7 @@ TBD
|
|
|
33
48
|
owner: user:guest
|
|
34
49
|
```
|
|
35
50
|
|
|
36
|
-
###
|
|
51
|
+
### Installation
|
|
37
52
|
|
|
38
53
|
1. Install the plugin dependency in your Backstage app package:
|
|
39
54
|
|
|
@@ -42,7 +57,9 @@ TBD
|
|
|
42
57
|
yarn --cwd packages/app add @backstage-community/plugin-github-actions
|
|
43
58
|
```
|
|
44
59
|
|
|
45
|
-
|
|
60
|
+
### Integrating with `EntityPage`
|
|
61
|
+
|
|
62
|
+
1. Add to the app `EntityPage` component:
|
|
46
63
|
|
|
47
64
|
```tsx
|
|
48
65
|
// In packages/app/src/components/catalog/EntityPage.tsx
|
|
@@ -64,6 +81,39 @@ const serviceEntityPage = (
|
|
|
64
81
|
3. Run the app with `yarn start` and the backend with `yarn start-backend`.
|
|
65
82
|
Then navigate to `/github-actions/` under any entity.
|
|
66
83
|
|
|
84
|
+
### Integrating with `EntityPage` (New Frontend System)
|
|
85
|
+
|
|
86
|
+
Follow this section if you are using Backstage's [new frontend system](https://backstage.io/docs/frontend-system/).
|
|
87
|
+
|
|
88
|
+
1. Import `githubActionsPlugin` in your `App.tsx` and add it to your app's `features` array:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import githubActionsPlugin from '@backstage-community/plugin-github-actions/alpha';
|
|
92
|
+
|
|
93
|
+
// ...
|
|
94
|
+
|
|
95
|
+
export const app = createApp({
|
|
96
|
+
features: [
|
|
97
|
+
// ...
|
|
98
|
+
githubActionsPlugin,
|
|
99
|
+
// ...
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
2. Next, enable your desired extensions in `app-config.yaml`
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
app:
|
|
108
|
+
extensions:
|
|
109
|
+
- entity-content:github-actions/entity
|
|
110
|
+
- entity-card:github-actions/latest-workflow-run
|
|
111
|
+
- entity-card:github-actions/latest-branch-workflow-runs
|
|
112
|
+
- entity-card:github-actions/recent-workflow-runs
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
3. Whichever extensions you've enabled should now appear in your entity page.
|
|
116
|
+
|
|
67
117
|
### Self-hosted / Enterprise GitHub
|
|
68
118
|
|
|
69
119
|
The plugin will try to use `backstage.io/source-location` or `backstage.io/managed-by-location`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createApiExtension, createApiFactory, configApiRef } from '@backstage/frontend-plugin-api';
|
|
2
|
+
import { scmAuthApiRef } from '@backstage/integration-react';
|
|
3
|
+
import { githubActionsApiRef } from '../api/GithubActionsApi.esm.js';
|
|
4
|
+
import { GithubActionsClient } from '../api/GithubActionsClient.esm.js';
|
|
5
|
+
|
|
6
|
+
const githubActionsApi = createApiExtension({
|
|
7
|
+
factory: createApiFactory({
|
|
8
|
+
api: githubActionsApiRef,
|
|
9
|
+
deps: { configApi: configApiRef, scmAuthApi: scmAuthApiRef },
|
|
10
|
+
factory: ({ configApi, scmAuthApi }) => new GithubActionsClient({ configApi, scmAuthApi })
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { githubActionsApi };
|
|
15
|
+
//# sourceMappingURL=apis.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apis.esm.js","sources":["../../src/alpha/apis.ts"],"sourcesContent":["import {\n configApiRef,\n createApiExtension,\n createApiFactory,\n} from '@backstage/frontend-plugin-api';\nimport { scmAuthApiRef } from '@backstage/integration-react';\nimport { githubActionsApiRef, GithubActionsClient } from '../api';\n\n/**\n * @alpha\n */\nexport const githubActionsApi = createApiExtension({\n factory: createApiFactory({\n api: githubActionsApiRef,\n deps: { configApi: configApiRef, scmAuthApi: scmAuthApiRef },\n factory: ({ configApi, scmAuthApi }) =>\n new GithubActionsClient({ configApi, scmAuthApi }),\n }),\n});\n"],"names":[],"mappings":";;;;;AAWO,MAAM,mBAAmB,kBAAmB,CAAA;AAAA,EACjD,SAAS,gBAAiB,CAAA;AAAA,IACxB,GAAK,EAAA,mBAAA;AAAA,IACL,IAAM,EAAA,EAAE,SAAW,EAAA,YAAA,EAAc,YAAY,aAAc,EAAA;AAAA,IAC3D,OAAA,EAAS,CAAC,EAAE,SAAW,EAAA,UAAA,EACrB,KAAA,IAAI,mBAAoB,CAAA,EAAE,SAAW,EAAA,UAAA,EAAY,CAAA;AAAA,GACpD,CAAA;AACH,CAAC;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createSchemaFromZod } from '@backstage/frontend-plugin-api';
|
|
3
|
+
import { createEntityCardExtension } from '@backstage/plugin-catalog-react/alpha';
|
|
4
|
+
|
|
5
|
+
const entityGithubActionsCard = createEntityCardExtension({
|
|
6
|
+
name: "workflow-runs",
|
|
7
|
+
loader: () => import('../components/Router.esm.js').then((m) => /* @__PURE__ */ React.createElement(m.Router, { view: "cards" }))
|
|
8
|
+
});
|
|
9
|
+
const entityLatestGithubActionRunCard = createEntityCardExtension({
|
|
10
|
+
name: "latest-workflow-run",
|
|
11
|
+
configSchema: createSchemaFromZod(
|
|
12
|
+
(z) => z.object({
|
|
13
|
+
props: z.object({
|
|
14
|
+
branch: z.string().default("master")
|
|
15
|
+
}).default({}),
|
|
16
|
+
filter: z.string().optional()
|
|
17
|
+
})
|
|
18
|
+
),
|
|
19
|
+
loader: ({ config }) => import('../components/Cards/index.esm.js').then((m) => /* @__PURE__ */ React.createElement(m.LatestWorkflowRunCard, { ...config.props }))
|
|
20
|
+
});
|
|
21
|
+
const entityLatestGithubActionsForBranchCard = createEntityCardExtension(
|
|
22
|
+
{
|
|
23
|
+
name: "latest-branch-workflow-runs",
|
|
24
|
+
configSchema: createSchemaFromZod(
|
|
25
|
+
(z) => z.object({
|
|
26
|
+
props: z.object({
|
|
27
|
+
branch: z.string().default("master")
|
|
28
|
+
}).default({}),
|
|
29
|
+
filter: z.string().optional()
|
|
30
|
+
})
|
|
31
|
+
),
|
|
32
|
+
loader: ({ config }) => import('../components/Cards/index.esm.js').then((m) => /* @__PURE__ */ React.createElement(m.LatestWorkflowsForBranchCard, { ...config.props }))
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
const entityRecentGithubActionsRunsCard = createEntityCardExtension({
|
|
36
|
+
name: "recent-workflow-runs",
|
|
37
|
+
configSchema: createSchemaFromZod(
|
|
38
|
+
(z) => z.object({
|
|
39
|
+
props: z.object({
|
|
40
|
+
branch: z.string().default("master"),
|
|
41
|
+
dense: z.boolean().default(false),
|
|
42
|
+
limit: z.number().default(5).optional()
|
|
43
|
+
}).default({}),
|
|
44
|
+
filter: z.string().optional()
|
|
45
|
+
})
|
|
46
|
+
),
|
|
47
|
+
loader: ({ config }) => import('../components/Cards/index.esm.js').then((m) => /* @__PURE__ */ React.createElement(m.RecentWorkflowRunsCard, { ...config.props }))
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { entityGithubActionsCard, entityLatestGithubActionRunCard, entityLatestGithubActionsForBranchCard, entityRecentGithubActionsRunsCard };
|
|
51
|
+
//# sourceMappingURL=entityCards.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityCards.esm.js","sources":["../../src/alpha/entityCards.tsx"],"sourcesContent":["import React from 'react';\nimport { createSchemaFromZod } from '@backstage/frontend-plugin-api';\nimport { createEntityCardExtension } from '@backstage/plugin-catalog-react/alpha';\n\n/**\n * @alpha\n */\nexport const entityGithubActionsCard = createEntityCardExtension({\n name: 'workflow-runs',\n loader: () =>\n import('../components/Router').then(m => <m.Router view=\"cards\" />),\n});\n\n/**\n * @alpha\n */\nexport const entityLatestGithubActionRunCard = createEntityCardExtension({\n name: 'latest-workflow-run',\n configSchema: createSchemaFromZod(z =>\n z.object({\n props: z\n .object({\n branch: z.string().default('master'),\n })\n .default({}),\n filter: z.string().optional(),\n }),\n ),\n loader: ({ config }) =>\n import('../components/Cards').then(m => (\n <m.LatestWorkflowRunCard {...config.props} />\n )),\n});\n\n/**\n * @alpha\n */\nexport const entityLatestGithubActionsForBranchCard = createEntityCardExtension(\n {\n name: 'latest-branch-workflow-runs',\n configSchema: createSchemaFromZod(z =>\n z.object({\n props: z\n .object({\n branch: z.string().default('master'),\n })\n .default({}),\n filter: z.string().optional(),\n }),\n ),\n loader: ({ config }) =>\n import('../components/Cards').then(m => (\n <m.LatestWorkflowsForBranchCard {...config.props} />\n )),\n },\n);\n\n/**\n * @alpha\n */\nexport const entityRecentGithubActionsRunsCard = createEntityCardExtension({\n name: 'recent-workflow-runs',\n configSchema: createSchemaFromZod(z =>\n z.object({\n props: z\n .object({\n branch: z.string().default('master'),\n dense: z.boolean().default(false),\n limit: z.number().default(5).optional(),\n })\n .default({}),\n filter: z.string().optional(),\n }),\n ),\n loader: ({ config }) =>\n import('../components/Cards').then(m => (\n <m.RecentWorkflowRunsCard {...config.props} />\n )),\n});\n"],"names":[],"mappings":";;;;AAOO,MAAM,0BAA0B,yBAA0B,CAAA;AAAA,EAC/D,IAAM,EAAA,eAAA;AAAA,EACN,MAAQ,EAAA,MACN,OAAO,6BAAsB,CAAE,CAAA,IAAA,CAAK,CAAK,CAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,CAAE,CAAA,MAAA,EAAF,EAAS,IAAA,EAAK,SAAQ,CAAE,CAAA;AACtE,CAAC,EAAA;AAKM,MAAM,kCAAkC,yBAA0B,CAAA;AAAA,EACvE,IAAM,EAAA,qBAAA;AAAA,EACN,YAAc,EAAA,mBAAA;AAAA,IAAoB,CAAA,CAAA,KAChC,EAAE,MAAO,CAAA;AAAA,MACP,KAAA,EAAO,EACJ,MAAO,CAAA;AAAA,QACN,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAQ,QAAQ,CAAA;AAAA,OACpC,CAAA,CACA,OAAQ,CAAA,EAAE,CAAA;AAAA,MACb,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AAAA,EACA,QAAQ,CAAC,EAAE,MAAO,EAAA,KAChB,OAAO,kCAAqB,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,yCAChC,CAAE,CAAA,qBAAA,EAAF,EAAyB,GAAG,MAAA,CAAO,OAAO,CAC5C,CAAA;AACL,CAAC,EAAA;AAKM,MAAM,sCAAyC,GAAA,yBAAA;AAAA,EACpD;AAAA,IACE,IAAM,EAAA,6BAAA;AAAA,IACN,YAAc,EAAA,mBAAA;AAAA,MAAoB,CAAA,CAAA,KAChC,EAAE,MAAO,CAAA;AAAA,QACP,KAAA,EAAO,EACJ,MAAO,CAAA;AAAA,UACN,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAQ,QAAQ,CAAA;AAAA,SACpC,CAAA,CACA,OAAQ,CAAA,EAAE,CAAA;AAAA,QACb,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,OAC7B,CAAA;AAAA,KACH;AAAA,IACA,QAAQ,CAAC,EAAE,MAAO,EAAA,KAChB,OAAO,kCAAqB,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,yCAChC,CAAE,CAAA,4BAAA,EAAF,EAAgC,GAAG,MAAA,CAAO,OAAO,CACnD,CAAA;AAAA,GACL;AACF,EAAA;AAKO,MAAM,oCAAoC,yBAA0B,CAAA;AAAA,EACzE,IAAM,EAAA,sBAAA;AAAA,EACN,YAAc,EAAA,mBAAA;AAAA,IAAoB,CAAA,CAAA,KAChC,EAAE,MAAO,CAAA;AAAA,MACP,KAAA,EAAO,EACJ,MAAO,CAAA;AAAA,QACN,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAQ,QAAQ,CAAA;AAAA,QACnC,KAAO,EAAA,CAAA,CAAE,OAAQ,EAAA,CAAE,QAAQ,KAAK,CAAA;AAAA,QAChC,OAAO,CAAE,CAAA,MAAA,GAAS,OAAQ,CAAA,CAAC,EAAE,QAAS,EAAA;AAAA,OACvC,CAAA,CACA,OAAQ,CAAA,EAAE,CAAA;AAAA,MACb,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AAAA,EACA,QAAQ,CAAC,EAAE,MAAO,EAAA,KAChB,OAAO,kCAAqB,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,yCAChC,CAAE,CAAA,sBAAA,EAAF,EAA0B,GAAG,MAAA,CAAO,OAAO,CAC7C,CAAA;AACL,CAAC;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { convertLegacyRouteRef } from '@backstage/core-compat-api';
|
|
3
|
+
import { createEntityContentExtension } from '@backstage/plugin-catalog-react/alpha';
|
|
4
|
+
import { rootRouteRef } from '../routes.esm.js';
|
|
5
|
+
|
|
6
|
+
const entityGithubActionsContent = createEntityContentExtension({
|
|
7
|
+
defaultPath: "github-actions",
|
|
8
|
+
defaultTitle: "GitHub Actions",
|
|
9
|
+
name: "entity",
|
|
10
|
+
routeRef: convertLegacyRouteRef(rootRouteRef),
|
|
11
|
+
loader: () => import('../components/Router.esm.js').then((m) => /* @__PURE__ */ React.createElement(m.Router, { view: "table" }))
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { entityGithubActionsContent };
|
|
15
|
+
//# sourceMappingURL=entityContent.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityContent.esm.js","sources":["../../src/alpha/entityContent.tsx"],"sourcesContent":["import React from 'react';\nimport { convertLegacyRouteRef } from '@backstage/core-compat-api';\nimport { createEntityContentExtension } from '@backstage/plugin-catalog-react/alpha';\nimport { rootRouteRef } from '../routes';\n\n/**\n * @alpha\n */\nexport const entityGithubActionsContent = createEntityContentExtension({\n defaultPath: 'github-actions',\n defaultTitle: 'GitHub Actions',\n name: 'entity',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('../components/Router').then(m => <m.Router view=\"table\" />),\n});\n"],"names":[],"mappings":";;;;;AAQO,MAAM,6BAA6B,4BAA6B,CAAA;AAAA,EACrE,WAAa,EAAA,gBAAA;AAAA,EACb,YAAc,EAAA,gBAAA;AAAA,EACd,IAAM,EAAA,QAAA;AAAA,EACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,EAC5C,MAAQ,EAAA,MACN,OAAO,6BAAsB,CAAE,CAAA,IAAA,CAAK,CAAK,CAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,CAAE,CAAA,MAAA,EAAF,EAAS,IAAA,EAAK,SAAQ,CAAE,CAAA;AACtE,CAAC;;;;"}
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @alpha
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: _backstage_frontend_plugin_api.BackstagePlugin<{
|
|
7
|
+
entityContent: _backstage_frontend_plugin_api.RouteRef<undefined>;
|
|
8
|
+
}, {}>;
|
|
9
|
+
|
|
10
|
+
export { _default as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { convertLegacyRouteRefs } from '@backstage/core-compat-api';
|
|
2
|
+
import { createPlugin } from '@backstage/frontend-plugin-api';
|
|
3
|
+
import { githubActionsApi } from './alpha/apis.esm.js';
|
|
4
|
+
import { entityGithubActionsCard, entityLatestGithubActionRunCard, entityLatestGithubActionsForBranchCard, entityRecentGithubActionsRunsCard } from './alpha/entityCards.esm.js';
|
|
5
|
+
import { entityGithubActionsContent } from './alpha/entityContent.esm.js';
|
|
6
|
+
import { rootRouteRef } from './routes.esm.js';
|
|
7
|
+
|
|
8
|
+
var alpha = createPlugin({
|
|
9
|
+
id: "github-actions",
|
|
10
|
+
routes: convertLegacyRouteRefs({
|
|
11
|
+
entityContent: rootRouteRef
|
|
12
|
+
}),
|
|
13
|
+
extensions: [
|
|
14
|
+
entityGithubActionsContent,
|
|
15
|
+
entityGithubActionsCard,
|
|
16
|
+
entityLatestGithubActionRunCard,
|
|
17
|
+
entityLatestGithubActionsForBranchCard,
|
|
18
|
+
entityRecentGithubActionsRunsCard,
|
|
19
|
+
githubActionsApi
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { alpha as default };
|
|
24
|
+
//# sourceMappingURL=alpha.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.ts"],"sourcesContent":["import { convertLegacyRouteRefs } from '@backstage/core-compat-api';\nimport { createPlugin } from '@backstage/frontend-plugin-api';\nimport {\n entityGithubActionsCard,\n entityGithubActionsContent,\n entityLatestGithubActionRunCard,\n entityLatestGithubActionsForBranchCard,\n entityRecentGithubActionsRunsCard,\n githubActionsApi,\n} from './alpha/index';\nimport { rootRouteRef } from './routes';\n\n/**\n * @alpha\n */\nexport default createPlugin({\n id: 'github-actions',\n routes: convertLegacyRouteRefs({\n entityContent: rootRouteRef,\n }),\n extensions: [\n entityGithubActionsContent,\n entityGithubActionsCard,\n entityLatestGithubActionRunCard,\n entityLatestGithubActionsForBranchCard,\n entityRecentGithubActionsRunsCard,\n githubActionsApi,\n ],\n});\n"],"names":[],"mappings":";;;;;;;AAeA,YAAe,YAAa,CAAA;AAAA,EAC1B,EAAI,EAAA,gBAAA;AAAA,EACJ,QAAQ,sBAAuB,CAAA;AAAA,IAC7B,aAAe,EAAA,YAAA;AAAA,GAChB,CAAA;AAAA,EACD,UAAY,EAAA;AAAA,IACV,0BAAA;AAAA,IACA,uBAAA;AAAA,IACA,+BAAA;AAAA,IACA,sCAAA;AAAA,IACA,iCAAA;AAAA,IACA,gBAAA;AAAA,GACF;AACF,CAAC,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GithubActionsApi.esm.js","sources":["../../src/api/GithubActionsApi.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createApiRef } from '@backstage/frontend-plugin-api';\nimport { RestEndpointMethodTypes } from '@octokit/rest';\n\n/** @public */\nexport const githubActionsApiRef = createApiRef<GithubActionsApi>({\n id: 'plugin.githubactions.service',\n});\n\n/**\n * A client for fetching information about GitHub actions.\n *\n * @public\n */\nexport type GithubActionsApi = {\n listWorkflowRuns: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n pageSize?: number;\n page?: number;\n branch?: string;\n }) => Promise<\n RestEndpointMethodTypes['actions']['listWorkflowRuns']['response']['data']\n >;\n\n getWorkflow: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n id: number;\n }) => Promise<\n RestEndpointMethodTypes['actions']['getWorkflow']['response']['data']\n >;\n\n getWorkflowRun: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n id: number;\n }) => Promise<\n RestEndpointMethodTypes['actions']['getWorkflowRun']['response']['data']\n >;\n\n reRunWorkflow: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n runId: number;\n }) => Promise<any>;\n\n listJobsForWorkflowRun: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n id: number;\n pageSize?: number;\n page?: number;\n }) => Promise<\n RestEndpointMethodTypes['actions']['listJobsForWorkflowRun']['response']['data']\n >;\n\n downloadJobLogsForWorkflowRun: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n runId: number;\n }) => Promise<\n RestEndpointMethodTypes['actions']['downloadJobLogsForWorkflowRun']['response']['data']\n >;\n\n listBranches: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n page: number;\n }) => Promise<\n RestEndpointMethodTypes['repos']['listBranches']['response']['data']\n >;\n\n getDefaultBranch: (options: {\n hostname?: string;\n owner: string;\n repo: string;\n }) => Promise<\n RestEndpointMethodTypes['repos']['get']['response']['data']['default_branch']\n >;\n};\n"],"names":[],"mappings":";;AAoBO,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA,8BAAA;AACN,CAAC;;;;"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { readGithubIntegrationConfigs } from '@backstage/integration';
|
|
2
|
+
import { Octokit } from '@octokit/rest';
|
|
3
|
+
|
|
4
|
+
class GithubActionsClient {
|
|
5
|
+
configApi;
|
|
6
|
+
scmAuthApi;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.configApi = options.configApi;
|
|
9
|
+
this.scmAuthApi = options.scmAuthApi;
|
|
10
|
+
}
|
|
11
|
+
async getOctokit(hostname = "github.com") {
|
|
12
|
+
const { token } = await this.scmAuthApi.getCredentials({
|
|
13
|
+
url: `https://${hostname}/`,
|
|
14
|
+
additionalScope: {
|
|
15
|
+
customScopes: {
|
|
16
|
+
github: ["repo"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const configs = readGithubIntegrationConfigs(
|
|
21
|
+
this.configApi.getOptionalConfigArray("integrations.github") ?? []
|
|
22
|
+
);
|
|
23
|
+
const githubIntegrationConfig = configs.find((v) => v.host === hostname);
|
|
24
|
+
const baseUrl = githubIntegrationConfig?.apiBaseUrl;
|
|
25
|
+
return new Octokit({ auth: token, baseUrl });
|
|
26
|
+
}
|
|
27
|
+
async reRunWorkflow(options) {
|
|
28
|
+
const { hostname, owner, repo, runId } = options;
|
|
29
|
+
const octokit = await this.getOctokit(hostname);
|
|
30
|
+
return octokit.actions.reRunWorkflow({
|
|
31
|
+
owner,
|
|
32
|
+
repo,
|
|
33
|
+
run_id: runId
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async listWorkflowRuns(options) {
|
|
37
|
+
const { hostname, owner, repo, pageSize = 100, page = 0, branch } = options;
|
|
38
|
+
const octokit = await this.getOctokit(hostname);
|
|
39
|
+
const workflowRuns = await octokit.actions.listWorkflowRunsForRepo({
|
|
40
|
+
owner,
|
|
41
|
+
repo,
|
|
42
|
+
per_page: pageSize,
|
|
43
|
+
page,
|
|
44
|
+
...branch ? { branch } : {}
|
|
45
|
+
});
|
|
46
|
+
return workflowRuns.data;
|
|
47
|
+
}
|
|
48
|
+
async getWorkflow(options) {
|
|
49
|
+
const { hostname, owner, repo, id } = options;
|
|
50
|
+
const octokit = await this.getOctokit(hostname);
|
|
51
|
+
const workflow = await octokit.actions.getWorkflow({
|
|
52
|
+
owner,
|
|
53
|
+
repo,
|
|
54
|
+
workflow_id: id
|
|
55
|
+
});
|
|
56
|
+
return workflow.data;
|
|
57
|
+
}
|
|
58
|
+
async getWorkflowRun(options) {
|
|
59
|
+
const { hostname, owner, repo, id } = options;
|
|
60
|
+
const octokit = await this.getOctokit(hostname);
|
|
61
|
+
const run = await octokit.actions.getWorkflowRun({
|
|
62
|
+
owner,
|
|
63
|
+
repo,
|
|
64
|
+
run_id: id
|
|
65
|
+
});
|
|
66
|
+
return run.data;
|
|
67
|
+
}
|
|
68
|
+
async listJobsForWorkflowRun(options) {
|
|
69
|
+
const { hostname, owner, repo, id, pageSize = 100, page = 0 } = options;
|
|
70
|
+
const octokit = await this.getOctokit(hostname);
|
|
71
|
+
const jobs = await octokit.actions.listJobsForWorkflowRun({
|
|
72
|
+
owner,
|
|
73
|
+
repo,
|
|
74
|
+
run_id: id,
|
|
75
|
+
per_page: pageSize,
|
|
76
|
+
page
|
|
77
|
+
});
|
|
78
|
+
return jobs.data;
|
|
79
|
+
}
|
|
80
|
+
async downloadJobLogsForWorkflowRun(options) {
|
|
81
|
+
const { hostname, owner, repo, runId } = options;
|
|
82
|
+
const octokit = await this.getOctokit(hostname);
|
|
83
|
+
const workflow = await octokit.actions.downloadJobLogsForWorkflowRun({
|
|
84
|
+
owner,
|
|
85
|
+
repo,
|
|
86
|
+
job_id: runId
|
|
87
|
+
});
|
|
88
|
+
return workflow.data;
|
|
89
|
+
}
|
|
90
|
+
async listBranches(options) {
|
|
91
|
+
const { hostname, owner, repo, page = 0 } = options;
|
|
92
|
+
const octokit = await this.getOctokit(hostname);
|
|
93
|
+
const response = await octokit.rest.repos.listBranches({
|
|
94
|
+
owner,
|
|
95
|
+
repo,
|
|
96
|
+
per_page: 100,
|
|
97
|
+
page
|
|
98
|
+
});
|
|
99
|
+
return response.data;
|
|
100
|
+
}
|
|
101
|
+
async getDefaultBranch(options) {
|
|
102
|
+
const { hostname, owner, repo } = options;
|
|
103
|
+
const octokit = await this.getOctokit(hostname);
|
|
104
|
+
const response = await octokit.rest.repos.get({
|
|
105
|
+
owner,
|
|
106
|
+
repo
|
|
107
|
+
});
|
|
108
|
+
return response.data.default_branch;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { GithubActionsClient };
|
|
113
|
+
//# sourceMappingURL=GithubActionsClient.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GithubActionsClient.esm.js","sources":["../../src/api/GithubActionsClient.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readGithubIntegrationConfigs } from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { GithubActionsApi } from './GithubActionsApi';\nimport { Octokit, RestEndpointMethodTypes } from '@octokit/rest';\nimport { ConfigApi } from '@backstage/core-plugin-api';\n\n/**\n * A client for fetching information about GitHub actions.\n *\n * @public\n */\nexport class GithubActionsClient implements GithubActionsApi {\n private readonly configApi: ConfigApi;\n private readonly scmAuthApi: ScmAuthApi;\n\n constructor(options: { configApi: ConfigApi; scmAuthApi: ScmAuthApi }) {\n this.configApi = options.configApi;\n this.scmAuthApi = options.scmAuthApi;\n }\n\n private async getOctokit(hostname: string = 'github.com'): Promise<Octokit> {\n const { token } = await this.scmAuthApi.getCredentials({\n url: `https://${hostname}/`,\n additionalScope: {\n customScopes: {\n github: ['repo'],\n },\n },\n });\n const configs = readGithubIntegrationConfigs(\n this.configApi.getOptionalConfigArray('integrations.github') ?? [],\n );\n const githubIntegrationConfig = configs.find(v => v.host === hostname);\n const baseUrl = githubIntegrationConfig?.apiBaseUrl;\n return new Octokit({ auth: token, baseUrl });\n }\n\n async reRunWorkflow(options: {\n hostname?: string;\n owner: string;\n repo: string;\n runId: number;\n }): Promise<any> {\n const { hostname, owner, repo, runId } = options;\n\n const octokit = await this.getOctokit(hostname);\n return octokit.actions.reRunWorkflow({\n owner,\n repo,\n run_id: runId,\n });\n }\n\n async listWorkflowRuns(options: {\n hostname?: string;\n owner: string;\n repo: string;\n pageSize?: number;\n page?: number;\n branch?: string;\n }): Promise<\n RestEndpointMethodTypes['actions']['listWorkflowRuns']['response']['data']\n > {\n const { hostname, owner, repo, pageSize = 100, page = 0, branch } = options;\n\n const octokit = await this.getOctokit(hostname);\n const workflowRuns = await octokit.actions.listWorkflowRunsForRepo({\n owner,\n repo,\n per_page: pageSize,\n page,\n ...(branch ? { branch } : {}),\n });\n\n return workflowRuns.data;\n }\n\n async getWorkflow(options: {\n hostname?: string;\n owner: string;\n repo: string;\n id: number;\n }): Promise<\n RestEndpointMethodTypes['actions']['getWorkflow']['response']['data']\n > {\n const { hostname, owner, repo, id } = options;\n\n const octokit = await this.getOctokit(hostname);\n const workflow = await octokit.actions.getWorkflow({\n owner,\n repo,\n workflow_id: id,\n });\n\n return workflow.data;\n }\n\n async getWorkflowRun(options: {\n hostname?: string;\n owner: string;\n repo: string;\n id: number;\n }): Promise<\n RestEndpointMethodTypes['actions']['getWorkflowRun']['response']['data']\n > {\n const { hostname, owner, repo, id } = options;\n\n const octokit = await this.getOctokit(hostname);\n const run = await octokit.actions.getWorkflowRun({\n owner,\n repo,\n run_id: id,\n });\n\n return run.data;\n }\n\n async listJobsForWorkflowRun(options: {\n hostname?: string;\n owner: string;\n repo: string;\n id: number;\n pageSize?: number;\n page?: number;\n }): Promise<\n RestEndpointMethodTypes['actions']['listJobsForWorkflowRun']['response']['data']\n > {\n const { hostname, owner, repo, id, pageSize = 100, page = 0 } = options;\n\n const octokit = await this.getOctokit(hostname);\n const jobs = await octokit.actions.listJobsForWorkflowRun({\n owner,\n repo,\n run_id: id,\n per_page: pageSize,\n page,\n });\n\n return jobs.data;\n }\n\n async downloadJobLogsForWorkflowRun(options: {\n hostname?: string;\n owner: string;\n repo: string;\n runId: number;\n }): Promise<\n RestEndpointMethodTypes['actions']['downloadJobLogsForWorkflowRun']['response']['data']\n > {\n const { hostname, owner, repo, runId } = options;\n\n const octokit = await this.getOctokit(hostname);\n const workflow = await octokit.actions.downloadJobLogsForWorkflowRun({\n owner,\n repo,\n job_id: runId,\n });\n\n return workflow.data;\n }\n\n async listBranches(options: {\n hostname?: string;\n owner: string;\n repo: string;\n page?: number;\n }): Promise<\n RestEndpointMethodTypes['repos']['listBranches']['response']['data']\n > {\n const { hostname, owner, repo, page = 0 } = options;\n const octokit = await this.getOctokit(hostname);\n const response = await octokit.rest.repos.listBranches({\n owner,\n repo,\n per_page: 100,\n page,\n });\n\n return response.data;\n }\n\n async getDefaultBranch(options: {\n hostname?: string;\n owner: string;\n repo: string;\n }): Promise<\n RestEndpointMethodTypes['repos']['get']['response']['data']['default_branch']\n > {\n const { hostname, owner, repo } = options;\n const octokit = await this.getOctokit(hostname);\n const response = await octokit.rest.repos.get({\n owner,\n repo,\n });\n\n return response.data.default_branch;\n }\n}\n"],"names":[],"mappings":";;;AA2BO,MAAM,mBAAgD,CAAA;AAAA,EAC1C,SAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EAEjB,YAAY,OAA2D,EAAA;AACrE,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA,CAAA;AACzB,IAAA,IAAA,CAAK,aAAa,OAAQ,CAAA,UAAA,CAAA;AAAA,GAC5B;AAAA,EAEA,MAAc,UAAW,CAAA,QAAA,GAAmB,YAAgC,EAAA;AAC1E,IAAA,MAAM,EAAE,KAAM,EAAA,GAAI,MAAM,IAAA,CAAK,WAAW,cAAe,CAAA;AAAA,MACrD,GAAA,EAAK,WAAW,QAAQ,CAAA,CAAA,CAAA;AAAA,MACxB,eAAi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,GAAA,OAAA,CAAA;AAClC,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,UAAA,CAAW,QAAQ,CAAA,CAAA;AAC9C,IAAA,MAAM,QAAW,GAAA,MAAM,OAAQ,CAAA,IAAA,CAAK,MAAM,GAAI,CAAA;AAAA,MAC5C,KAAA;AAAA,MACA,IAAA;AAAA,KACD,CAAA,CAAA;AAED,IAAA,OAAO,SAAS,IAAK,CAAA,cAAA,CAAA;AAAA,GACvB;AACF;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var BuildStatus = /* @__PURE__ */ ((BuildStatus2) => {
|
|
2
|
+
BuildStatus2[BuildStatus2["success"] = 0] = "success";
|
|
3
|
+
BuildStatus2[BuildStatus2["failure"] = 1] = "failure";
|
|
4
|
+
BuildStatus2[BuildStatus2["pending"] = 2] = "pending";
|
|
5
|
+
BuildStatus2[BuildStatus2["running"] = 3] = "running";
|
|
6
|
+
return BuildStatus2;
|
|
7
|
+
})(BuildStatus || {});
|
|
8
|
+
|
|
9
|
+
export { BuildStatus };
|
|
10
|
+
//# sourceMappingURL=types.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../../src/api/types.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @public */\nexport type Step = {\n name: string;\n status: string;\n conclusion?: string;\n number: number; // starts from 1\n started_at?: string;\n completed_at?: string;\n};\n\n/** @public */\nexport type Job = {\n html_url?: string;\n status: string;\n conclusion?: string;\n started_at: string;\n completed_at?: string;\n id: number;\n name: string;\n steps?: Step[];\n};\n\n/** @public */\nexport type Jobs = {\n total_count: number;\n jobs: Job[];\n};\n\n/** @public */\nexport enum BuildStatus {\n 'success',\n 'failure',\n 'pending',\n 'running',\n}\n\n/** @public */\nexport type Branch = {\n name: string;\n};\n\n/** @public */\nexport type Branches = {\n default_branch: string;\n branches: Branch[];\n};\n\n/** @public */\nexport interface RouterProps {\n view?: 'cards' | 'table';\n}\n"],"names":["BuildStatus"],"mappings":"AA6CY,IAAA,WAAA,qBAAAA,YAAL,KAAA;AACL,EAAAA,YAAA,CAAA,YAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,YAAA,CAAA,YAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,YAAA,CAAA,YAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,YAAA,CAAA,YAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AAJU,EAAAA,OAAAA,YAAAA,CAAAA;AAAA,CAAA,EAAA,WAAA,IAAA,EAAA;;;;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
2
|
+
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
import ExternalLinkIcon from '@material-ui/icons/Launch';
|
|
6
|
+
import React, { useEffect } from 'react';
|
|
7
|
+
import { GITHUB_ACTIONS_ANNOTATION } from '../getProjectNameFromEntity.esm.js';
|
|
8
|
+
import { useWorkflowRuns } from '../useWorkflowRuns.esm.js';
|
|
9
|
+
import { WorkflowRunsTable } from '../WorkflowRunsTable/WorkflowRunsTable.esm.js';
|
|
10
|
+
import { WorkflowRunStatus } from '../WorkflowRunStatus/WorkflowRunStatus.esm.js';
|
|
11
|
+
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
|
|
12
|
+
import { InfoCard, StructuredMetadataTable, Link } from '@backstage/core-components';
|
|
13
|
+
import { getHostnameFromEntity } from '../getHostnameFromEntity.esm.js';
|
|
14
|
+
|
|
15
|
+
const useStyles = makeStyles({
|
|
16
|
+
externalLinkIcon: {
|
|
17
|
+
fontSize: "inherit",
|
|
18
|
+
verticalAlign: "bottom"
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const WidgetContent = (props) => {
|
|
22
|
+
const { error, loading, lastRun, branch } = props;
|
|
23
|
+
const classes = useStyles();
|
|
24
|
+
if (error) return /* @__PURE__ */ React.createElement(Typography, null, "Couldn't fetch latest ", branch, " run");
|
|
25
|
+
if (loading) return /* @__PURE__ */ React.createElement(LinearProgress, null);
|
|
26
|
+
return /* @__PURE__ */ React.createElement(
|
|
27
|
+
StructuredMetadataTable,
|
|
28
|
+
{
|
|
29
|
+
metadata: {
|
|
30
|
+
status: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
31
|
+
WorkflowRunStatus,
|
|
32
|
+
{
|
|
33
|
+
status: lastRun.status,
|
|
34
|
+
conclusion: lastRun.conclusion
|
|
35
|
+
}
|
|
36
|
+
)),
|
|
37
|
+
message: lastRun.message,
|
|
38
|
+
url: /* @__PURE__ */ React.createElement(Link, { to: lastRun.githubUrl ?? "" }, "See more on GitHub", " ", /* @__PURE__ */ React.createElement(ExternalLinkIcon, { className: classes.externalLinkIcon }))
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
const LatestWorkflowRunCard = (props) => {
|
|
44
|
+
const { branch = "master", variant } = props;
|
|
45
|
+
const { entity } = useEntity();
|
|
46
|
+
const errorApi = useApi(errorApiRef);
|
|
47
|
+
const hostname = getHostnameFromEntity(entity);
|
|
48
|
+
const [owner, repo] = (entity?.metadata.annotations?.[GITHUB_ACTIONS_ANNOTATION] ?? "/").split("/");
|
|
49
|
+
const [{ runs, loading, error }] = useWorkflowRuns({
|
|
50
|
+
hostname,
|
|
51
|
+
owner,
|
|
52
|
+
repo,
|
|
53
|
+
branch
|
|
54
|
+
});
|
|
55
|
+
const lastRun = runs?.[0] ?? {};
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (error) {
|
|
58
|
+
errorApi.post(error);
|
|
59
|
+
}
|
|
60
|
+
}, [error, errorApi]);
|
|
61
|
+
return /* @__PURE__ */ React.createElement(InfoCard, { title: `Last ${branch} build`, variant }, /* @__PURE__ */ React.createElement(
|
|
62
|
+
WidgetContent,
|
|
63
|
+
{
|
|
64
|
+
error,
|
|
65
|
+
loading,
|
|
66
|
+
branch,
|
|
67
|
+
lastRun
|
|
68
|
+
}
|
|
69
|
+
));
|
|
70
|
+
};
|
|
71
|
+
const LatestWorkflowsForBranchCard = (props) => {
|
|
72
|
+
const { branch = "master", variant } = props;
|
|
73
|
+
const { entity } = useEntity();
|
|
74
|
+
return /* @__PURE__ */ React.createElement(InfoCard, { title: `Last ${branch} build`, variant }, /* @__PURE__ */ React.createElement(WorkflowRunsTable, { branch, entity }));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { LatestWorkflowRunCard, LatestWorkflowsForBranchCard };
|
|
78
|
+
//# sourceMappingURL=Cards.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cards.esm.js","sources":["../../../src/components/Cards/Cards.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExternalLinkIcon from '@material-ui/icons/Launch';\nimport React, { useEffect } from 'react';\nimport { GITHUB_ACTIONS_ANNOTATION } from '../getProjectNameFromEntity';\nimport { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';\nimport { WorkflowRunsTable } from '../WorkflowRunsTable';\nimport { WorkflowRunStatus } from '../WorkflowRunStatus';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n InfoCard,\n InfoCardVariants,\n Link,\n StructuredMetadataTable,\n} from '@backstage/core-components';\nimport { getHostnameFromEntity } from '../getHostnameFromEntity';\n\nconst useStyles = makeStyles({\n externalLinkIcon: {\n fontSize: 'inherit',\n verticalAlign: 'bottom',\n },\n});\n\nconst WidgetContent = (props: {\n error?: Error;\n loading?: boolean;\n lastRun: WorkflowRun;\n branch: string;\n}) => {\n const { error, loading, lastRun, branch } = props;\n const classes = useStyles();\n\n if (error) return <Typography>Couldn't fetch latest {branch} run</Typography>;\n if (loading) return <LinearProgress />;\n\n return (\n <StructuredMetadataTable\n metadata={{\n status: (\n <>\n <WorkflowRunStatus\n status={lastRun.status}\n conclusion={lastRun.conclusion}\n />\n </>\n ),\n message: lastRun.message,\n url: (\n <Link to={lastRun.githubUrl ?? ''}>\n See more on GitHub{' '}\n <ExternalLinkIcon className={classes.externalLinkIcon} />\n </Link>\n ),\n }}\n />\n );\n};\n\n/** @public */\nexport const LatestWorkflowRunCard = (props: {\n branch?: string;\n variant?: InfoCardVariants;\n}) => {\n const { branch = 'master', variant } = props;\n const { entity } = useEntity();\n const errorApi = useApi(errorApiRef);\n const hostname = getHostnameFromEntity(entity);\n const [owner, repo] = (\n entity?.metadata.annotations?.[GITHUB_ACTIONS_ANNOTATION] ?? '/'\n ).split('/');\n const [{ runs, loading, error }] = useWorkflowRuns({\n hostname,\n owner,\n repo,\n branch,\n });\n const lastRun = runs?.[0] ?? ({} as WorkflowRun);\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n return (\n <InfoCard title={`Last ${branch} build`} variant={variant}>\n <WidgetContent\n error={error}\n loading={loading}\n branch={branch}\n lastRun={lastRun}\n />\n </InfoCard>\n );\n};\n\n/** @public */\nexport const LatestWorkflowsForBranchCard = (props: {\n branch?: string;\n variant?: InfoCardVariants;\n}) => {\n const { branch = 'master', variant } = props;\n const { entity } = useEntity();\n\n return (\n <InfoCard title={`Last ${branch} build`} variant={variant}>\n <WorkflowRunsTable branch={branch} entity={entity} />\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,gBAAkB,EAAA;AAAA,IAChB,QAAU,EAAA,SAAA;AAAA,IACV,aAAe,EAAA,QAAA;AAAA,GACjB;AACF,CAAC,CAAA,CAAA;AAED,MAAM,aAAA,GAAgB,CAAC,KAKjB,KAAA;AACJ,EAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,OAAA,EAAS,QAAW,GAAA,KAAA,CAAA;AAC5C,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EAAA,IAAI,OAAc,uBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,IAAA,EAAA,wBAAA,EAAuB,QAAO,MAAI,CAAA,CAAA;AAChE,EAAI,IAAA,OAAA,EAAgB,uBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,IAAA,CAAA,CAAA;AAEpC,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,uBAAA;AAAA,IAAA;AAAA,MACC,QAAU,EAAA;AAAA,QACR,wBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,iBAAA;AAAA,UAAA;AAAA,YAC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AAAA,KACrB;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,QAAQ,CAAC,CAAA,CAAA;AAEpB,EAAA,2CACG,QAAS,EAAA,EAAA,KAAA,EAAO,CAAQ,KAAA,EAAA,MAAM,UAAU,OACvC,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA;AAAA,KAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ,EAAA;AAGa,MAAA,4BAAA,GAA+B,CAAC,KAGvC,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,GAAS,QAAU,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;AACvC,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAE7B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,KAAA,EAAO,CAAQ,KAAA,EAAA,MAAM,CAAU,MAAA,CAAA,EAAA,OAAA,EAAA,kBACtC,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,EAAkB,MAAgB,EAAA,MAAA,EAAgB,CACrD,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { Link as Link$1 } from 'react-router-dom';
|
|
4
|
+
import { GITHUB_ACTIONS_ANNOTATION } from '../getProjectNameFromEntity.esm.js';
|
|
5
|
+
import { useWorkflowRuns } from '../useWorkflowRuns.esm.js';
|
|
6
|
+
import { WorkflowRunStatus } from '../WorkflowRunStatus/WorkflowRunStatus.esm.js';
|
|
7
|
+
import Typography from '@material-ui/core/Typography';
|
|
8
|
+
import { useApi, errorApiRef, useRouteRef } from '@backstage/core-plugin-api';
|
|
9
|
+
import { ErrorPanel, InfoCard, Link, Table } from '@backstage/core-components';
|
|
10
|
+
import { buildRouteRef } from '../../routes.esm.js';
|
|
11
|
+
import { getHostnameFromEntity } from '../getHostnameFromEntity.esm.js';
|
|
12
|
+
|
|
13
|
+
const firstLine = (message) => message.split("\n")[0];
|
|
14
|
+
const RecentWorkflowRunsCard = (props) => {
|
|
15
|
+
const { branch, dense = false, limit = 5, variant } = props;
|
|
16
|
+
const { entity } = useEntity();
|
|
17
|
+
const errorApi = useApi(errorApiRef);
|
|
18
|
+
const hostname = getHostnameFromEntity(entity);
|
|
19
|
+
const [owner, repo] = (entity?.metadata.annotations?.[GITHUB_ACTIONS_ANNOTATION] ?? "/").split("/");
|
|
20
|
+
const [{ runs = [], loading, error }] = useWorkflowRuns({
|
|
21
|
+
hostname,
|
|
22
|
+
owner,
|
|
23
|
+
repo,
|
|
24
|
+
branch,
|
|
25
|
+
initialPageSize: limit
|
|
26
|
+
});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (error) {
|
|
29
|
+
errorApi.post(error);
|
|
30
|
+
}
|
|
31
|
+
}, [error, errorApi]);
|
|
32
|
+
const githubHost = hostname || "github.com";
|
|
33
|
+
const routeLink = useRouteRef(buildRouteRef);
|
|
34
|
+
if (error) {
|
|
35
|
+
return /* @__PURE__ */ React.createElement(ErrorPanel, { title: error.message, error });
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ React.createElement(
|
|
38
|
+
InfoCard,
|
|
39
|
+
{
|
|
40
|
+
title: "Recent Workflow Runs",
|
|
41
|
+
subheader: branch ? `Branch: ${branch}` : "All Branches",
|
|
42
|
+
noPadding: true,
|
|
43
|
+
variant
|
|
44
|
+
},
|
|
45
|
+
!runs.length ? /* @__PURE__ */ React.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, "This component has GitHub Actions enabled, but no workflows were found."), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, /* @__PURE__ */ React.createElement(Link, { to: `https://${githubHost}/${owner}/${repo}/actions/new` }, "Create a new workflow"))) : /* @__PURE__ */ React.createElement(
|
|
46
|
+
Table,
|
|
47
|
+
{
|
|
48
|
+
isLoading: loading,
|
|
49
|
+
options: {
|
|
50
|
+
search: false,
|
|
51
|
+
paging: false,
|
|
52
|
+
padding: dense ? "dense" : "default",
|
|
53
|
+
toolbar: false
|
|
54
|
+
},
|
|
55
|
+
columns: [
|
|
56
|
+
{
|
|
57
|
+
title: "Commit Message",
|
|
58
|
+
field: "message",
|
|
59
|
+
render: (data) => /* @__PURE__ */ React.createElement(Link, { component: Link$1, to: routeLink({ id: data.id }) }, firstLine(data.message ?? ""))
|
|
60
|
+
},
|
|
61
|
+
{ title: "Branch", field: "source.branchName" },
|
|
62
|
+
{ title: "Status", field: "status", render: WorkflowRunStatus }
|
|
63
|
+
],
|
|
64
|
+
data: runs
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { RecentWorkflowRunsCard };
|
|
71
|
+
//# sourceMappingURL=RecentWorkflowRunsCard.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecentWorkflowRunsCard.esm.js","sources":["../../../src/components/Cards/RecentWorkflowRunsCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport React, { useEffect } from 'react';\nimport { Link as RouterLink } from 'react-router-dom';\nimport { GITHUB_ACTIONS_ANNOTATION } from '../getProjectNameFromEntity';\nimport { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';\nimport { WorkflowRunStatus } from '../WorkflowRunStatus';\nimport Typography from '@material-ui/core/Typography';\n\nimport { errorApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n ErrorPanel,\n InfoCard,\n InfoCardVariants,\n Link,\n Table,\n} from '@backstage/core-components';\nimport { buildRouteRef } from '../../routes';\nimport { getHostnameFromEntity } from '../getHostnameFromEntity';\n\nconst firstLine = (message: string): string => message.split('\\n')[0];\n\n/** @public */\nexport const RecentWorkflowRunsCard = (props: {\n branch?: string;\n dense?: boolean;\n limit?: number;\n variant?: InfoCardVariants;\n}) => {\n const { branch, dense = false, limit = 5, variant } = props;\n\n const { entity } = useEntity();\n const errorApi = useApi(errorApiRef);\n\n const hostname = getHostnameFromEntity(entity);\n\n const [owner, repo] = (\n entity?.metadata.annotations?.[GITHUB_ACTIONS_ANNOTATION] ?? '/'\n ).split('/');\n\n const [{ runs = [], loading, error }] = useWorkflowRuns({\n hostname,\n owner,\n repo,\n branch,\n initialPageSize: limit,\n });\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n const githubHost = hostname || 'github.com';\n const routeLink = useRouteRef(buildRouteRef);\n\n if (error) {\n return <ErrorPanel title={error.message} error={error} />;\n }\n\n return (\n <InfoCard\n title=\"Recent Workflow Runs\"\n subheader={branch ? `Branch: ${branch}` : 'All Branches'}\n noPadding\n variant={variant}\n >\n {!runs.length ? (\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n This component has GitHub Actions enabled, but no workflows were\n found.\n </Typography>\n <Typography variant=\"body2\">\n <Link to={`https://${githubHost}/${owner}/${repo}/actions/new`}>\n Create a new workflow\n </Link>\n </Typography>\n </div>\n ) : (\n <Table<WorkflowRun>\n isLoading={loading}\n options={{\n search: false,\n paging: false,\n padding: dense ? 'dense' : 'default',\n toolbar: false,\n }}\n columns={[\n {\n title: 'Commit Message',\n field: 'message',\n render: data => (\n <Link component={RouterLink} to={routeLink({ id: data.id! })}>\n {firstLine(data.message ?? '')}\n </Link>\n ),\n },\n { title: 'Branch', field: 'source.branchName' },\n { title: 'Status', field: 'status', render: WorkflowRunStatus },\n ]}\n data={runs}\n />\n )}\n </InfoCard>\n );\n};\n"],"names":["RouterLink"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,YAAY,CAAC,OAAA,KAA4B,QAAQ,KAAM,CAAA,IAAI,EAAE,CAAC,CAAA,CAAA;AAGvD,MAAA,sBAAA,GAAyB,CAAC,KAKjC,KAAA;AACJ,EAAA,MAAM,EAAE,MAAQ,EAAA,KAAA,GAAQ,OAAO,KAAQ,GAAA,CAAA,EAAG,SAAY,GAAA,KAAA,CAAA;AAEtD,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AAEnC,EAAM,MAAA,QAAA,GAAW,sBAAsB,MAAM,CAAA,CAAA;AAE7C,EAAM,MAAA,CAAC,KAAO,EAAA,IAAI,CAChB,GAAA,CAAA,MAAA,EAAQ,QAAS,CAAA,WAAA,GAAc,yBAAyB,CAAA,IAAK,GAC7D,EAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AAEX,EAAM,MAAA,CAAC,EAAE,IAAO,GAAA,IAAI,OAAS,EAAA,KAAA,EAAO,CAAA,GAAI,eAAgB,CAAA;AAAA,IACtD,QAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,eAAiB,EAAA,KAAA;AAAA,GAClB,CAAA,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,KAAO,EAAA;AACT,MAAA,QAAA,CAAS,KAAK,KAAK,CAAA,CAAA;AAAA,KACrB;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,QAAQ,CAAC,CAAA,CAAA;AAEpB,EAAA,MAAM,aAAa,QAAY,IAAA,YAAA,CAAA;AAC/B,EAAM,MAAA,SAAA,GAAY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