gh integration: actions + oauth

This commit is contained in:
Med Mouine 2024-04-19 11:13:31 -04:00
parent a92d2f2d17
commit 62dc31231b
7 changed files with 114 additions and 62 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
AUTH_GITHUB_CLIENT_ID=400cfa04377727669c97
AUTH_GITHUB_CLIENT_SECRET=f1ba2aafd884f564915fed034e856a81f36351e4

View File

@ -18,7 +18,7 @@ backend:
# Uncomment the following host directive to bind to specific interfaces
# host: 127.0.0.1
csp:
connect-src: ["'self'", 'http:', 'https:']
connect-src: ["'self'", "http:", "https:"]
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
# Default Helmet Content-Security-Policy values can be removed by setting the key to false
cors:
@ -29,19 +29,46 @@ backend:
# The production database configuration is stored in app-config.production.yaml
database:
client: better-sqlite3
connection: ':memory:'
connection: ":memory:"
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir
integrations:
github:
- host: github.com
# This is a Personal Access Token or PAT from GitHub. You can find out how to generate this token, and more information
# about setting up the GitHub integration here: https://backstage.io/docs/integrations/github/locations#configuration
token: ${GITHUB_TOKEN}
### Example for how to add your GitHub Enterprise instance using the API:
# - host: ghe.example.net
# apiBaseUrl: https://ghe.example.net/api/v3
# token: ${GHE_TOKEN}
apps:
- appId: 880885
webhookUrl: https://smee.io/Nj4FT0Aq729ugz7yunjy
clientId: Iv1.62e73edda444f42c
clientSecret: 3f723fe4e40239d3817cb0a6a1190b7a71e86395
webhookSecret: 707dd0e621c9fa7c00acd060e406d9f3a07fbe88
privateKey: |
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA3NUeQ8dwqOxLgxqhSs8XQT2rWWNeJDrtqhGLYoTkP9jcm+YV
NvqHT3mRbOlff9d1sk+lmLbtTQc/ToOTifwAyIHrHU0ZuGqAiQSKLNSFYYtEe/r6
bqaJMmClHXBLkNt027MIWHuU1nM6zsbAhizBRZbmpMyr/gOfgH4WzXeeM4RYlbwp
qTuj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MIh
Y5YCGkBksea/rpJtDtrnRHOMxq1y6JW7sDuqZwupgYGybawQaQ9F/Ua/6Nphsd//
1v9v/x2hfjAlxeKX4JWGUEe46b2RL7O57uQ+6e6qvNyqb68ETOMXd6WyhjhK6muB
Kjc5UQKBgQDGMob1La4FPI+qSYo8jw7xrk5Pl15RnFAbYmC7Jxsl6ilx4Y0d9q0o
EkcZ2Cft85Tx+Jnuzm2V8HnufqO4EVcmy44vGetsMMcuMqqtwYn/K51o1G4S49rR
knI0blhVopibXjvzViuJu+WrJyI98itcaYJUXd1u4osLpHk6Fd18oQ==
-----END RSA PRIVATE KEY-----
proxy:
### Example for how to add a proxy endpoint for the frontend.
@ -56,18 +83,20 @@ proxy:
# and an external cloud storage when deploying TechDocs for production use-case.
# https://backstage.io/docs/features/techdocs/how-to-guides#how-to-migrate-from-techdocs-basic-to-recommended-deployment-approach
techdocs:
builder: 'local' # Alternatives - 'external'
builder: "local" # Alternatives - 'external'
generator:
runIn: 'docker' # Alternatives - 'local'
runIn: "docker" # Alternatives - 'local'
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.
type: "local" # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.
auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
providers:
# See https://backstage.io/docs/auth/guest/provider
guest: {}
github:
development:
clientId: 400cfa04377727669c97
clientSecret: 5f058d2257c63dac4ef773a20369e01d0baea6bf
scaffolder:
# see https://backstage.io/docs/features/software-templates/configuration for software template options

View File

@ -14,6 +14,7 @@
"lint": "backstage-cli package lint"
},
"dependencies": {
"@backstage-community/plugin-github-actions": "^0.6.16",
"@backstage/app-defaults": "^1.5.4",
"@backstage/catalog-model": "^1.4.5",
"@backstage/cli": "^0.26.3",
@ -51,10 +52,10 @@
"devDependencies": {
"@backstage/test-utils": "^1.5.4",
"@playwright/test": "^1.32.3",
"@testing-library/dom": "^9.0.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0",
"@testing-library/dom": "^9.0.0",
"@types/react-dom": "*",
"cross-env": "^7.0.0"
},

View File

@ -37,6 +37,8 @@ import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
import { githubAuthApiRef } from '@backstage/core-plugin-api';
const app = createApp({
apis,
@ -58,7 +60,19 @@ const app = createApp({
});
},
components: {
SignInPage: props => <SignInPage {...props} auto providers={['guest']} />,
SignInPage: props => (
<SignInPage
{...props}
auto
provider={{
id: 'github-auth-provider',
title: 'GitHub',
message: 'Sign in using GitHub',
apiRef: githubAuthApiRef,
}}
/>
),
},
});

View File

@ -71,9 +71,8 @@ const cicdContent = (
// You can for example enforce that all components of type 'service' should use GitHubActions
<EntitySwitch>
<EntitySwitch.Case if={isGithubActionsAvailable}>
<EntityGithubActionsContent />
<EntityGithubActionsContent view='cards' />
</EntitySwitch.Case>
<EntitySwitch.Case>
<EmptyState
title="No CI/CD available for this entity"

View File

@ -26,6 +26,7 @@
"@backstage/plugin-auth-backend-module-guest-provider": "^0.1.3",
"@backstage/plugin-auth-node": "^0.4.12",
"@backstage/plugin-catalog-backend": "^1.21.1",
"@backstage/plugin-catalog-backend-module-github": "^0.6.0",
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "^0.1.15",
"@backstage/plugin-permission-backend": "^0.5.41",
"@backstage/plugin-permission-backend-module-allow-all-policy": "^0.1.14",

View File

@ -2136,6 +2136,26 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"
"@backstage-community/plugin-github-actions@^0.6.16":
version "0.6.16"
resolved "https://registry.yarnpkg.com/@backstage-community/plugin-github-actions/-/plugin-github-actions-0.6.16.tgz#03462f8e4fb2f3cca32ecd163e3c7c6f6d4a4e84"
integrity sha512-rgtsw+SzFPwJLNVra4VDEsXtjq1RJeoyGty1zirDHhjbs+tLVb6sJC5e/gRPkh3VK/elSeFw1CJbDJXhaOJ7cA==
dependencies:
"@backstage/catalog-model" "^1.4.5"
"@backstage/core-components" "^0.14.4"
"@backstage/core-plugin-api" "^1.9.2"
"@backstage/integration" "^1.10.0"
"@backstage/integration-react" "^1.1.26"
"@backstage/plugin-catalog-react" "^1.11.3"
"@material-ui/core" "^4.12.2"
"@material-ui/icons" "^4.9.1"
"@material-ui/lab" "4.0.0-alpha.61"
"@octokit/rest" "^19.0.3"
"@types/react" "^16.13.1 || ^17.0.0 || ^18.0.0"
git-url-parse "^14.0.0"
luxon "^3.0.0"
react-use "^17.2.4"
"@backstage/app-defaults@^1.5.4":
version "1.5.4"
resolved "https://registry.yarnpkg.com/@backstage/app-defaults/-/app-defaults-1.5.4.tgz#db646dfba05730100d9d6daf0d0c6cf4d4d84aaf"
@ -2999,6 +3019,30 @@
"@react-hookz/web" "^24.0.0"
"@types/react" "^16.13.1 || ^17.0.0 || ^18.0.0"
"@backstage/plugin-catalog-backend-module-github@^0.6.0":
version "0.6.0"
resolved "https://registry.yarnpkg.com/@backstage/plugin-catalog-backend-module-github/-/plugin-catalog-backend-module-github-0.6.0.tgz#58fb5d055ae7f44fd29829dd22ab69d42f31f523"
integrity sha512-4K5o7UQ8nqGupLr66tJ1EhwVWpx75xTXM/htCTMyTtW/J2hiI9BV+pCdr9ecqpjKQJMPgIuv0QoXv4VjczmYPA==
dependencies:
"@backstage/backend-common" "^0.21.7"
"@backstage/backend-plugin-api" "^0.6.17"
"@backstage/backend-tasks" "^0.5.22"
"@backstage/catalog-client" "^1.6.4"
"@backstage/catalog-model" "^1.4.5"
"@backstage/config" "^1.2.0"
"@backstage/integration" "^1.10.0"
"@backstage/plugin-catalog-backend" "^1.21.1"
"@backstage/plugin-catalog-common" "^1.0.22"
"@backstage/plugin-catalog-node" "^1.11.1"
"@backstage/plugin-events-node" "^0.3.3"
"@octokit/graphql" "^5.0.0"
"@octokit/rest" "^19.0.3"
git-url-parse "^14.0.0"
lodash "^4.17.21"
minimatch "^9.0.0"
node-fetch "^2.6.7"
uuid "^9.0.0"
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model@^0.1.15":
version "0.1.15"
resolved "https://registry.yarnpkg.com/@backstage/plugin-catalog-backend-module-scaffolder-entity-model/-/plugin-catalog-backend-module-scaffolder-entity-model-0.1.15.tgz#bb15e0f5a27091d3f224e73c95dd3756574e2d74"
@ -8978,7 +9022,7 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==
"@types/react-dom@*", "@types/react-dom@^18.0.0":
"@types/react-dom@*", "@types/react-dom@^18", "@types/react-dom@^18.0.0":
version "18.2.25"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.25.tgz#2946a30081f53e7c8d585eb138277245caedc521"
integrity sha512-o/V48vf4MQh7juIKZU2QGDfli6p1+OOi5oXx36Hffpc9adsHeXjVp8rHuPkjd8VT8sOJ2Zp05HR7CdpGTIUFUA==
@ -9016,7 +9060,7 @@
dependencies:
"@types/react" "*"
"@types/react@*", "@types/react@^16.13.1 || ^17.0.0 || ^18.0.0":
"@types/react@*", "@types/react@^16.13.1 || ^17.0.0", "@types/react@^16.13.1 || ^17.0.0 || ^18.0.0", "@types/react@^18":
version "18.2.79"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.79.tgz#c40efb4f255711f554d47b449f796d1c7756d865"
integrity sha512-RwGAGXPl9kSXwdNTafkOEuFrTBD5SA2B3iEB96xi8+xu5ddUa/cpvyVCSNn+asgLCTHkb5ZxN8gbuibYJi4s1w==
@ -9024,15 +9068,6 @@
"@types/prop-types" "*"
csstype "^3.0.2"
"@types/react@^16.13.1 || ^17.0.0":
version "17.0.80"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.80.tgz#a5dfc351d6a41257eb592d73d3a85d3b7dbcbb41"
integrity sha512-LrgHIu2lEtIo8M7d1FcI3BdwXWoRQwMoXOZ7+dPTW0lYREjmlHl3P0U1VD0i/9tppOuv8/sam7sOjx34TxSFbA==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "^0.16"
csstype "^3.0.2"
"@types/request@^2.47.1", "@types/request@^2.48.8":
version "2.48.12"
resolved "https://registry.yarnpkg.com/@types/request/-/request-2.48.12.tgz#0f590f615a10f87da18e9790ac94c29ec4c5ef30"
@ -9065,11 +9100,6 @@
resolved "https://registry.yarnpkg.com/@types/sarif/-/sarif-2.1.7.tgz#dab4d16ba7568e9846c454a8764f33c5d98e5524"
integrity sha512-kRz0VEkJqWLf1LLVN4pT1cg1Z9wAuvI6L97V3m2f5B76Tg8d413ddvLBPTEHAZJlnn4XSvu0FkZtViCQGVyrXQ==
"@types/scheduler@^0.16":
version "0.16.8"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff"
integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==
"@types/semver@^7.3.12", "@types/semver@^7.5.0":
version "7.5.8"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
@ -9816,6 +9846,7 @@ anymatch@^3.0.3, anymatch@~3.1.2:
"app@link:packages/app":
version "0.0.0"
dependencies:
"@backstage-community/plugin-github-actions" "^0.6.16"
"@backstage/app-defaults" "^1.5.4"
"@backstage/catalog-model" "^1.4.5"
"@backstage/cli" "^0.26.3"
@ -22238,16 +22269,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@ -22325,7 +22347,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6.0, strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@ -22339,13 +22361,6 @@ strip-ansi@5.2.0:
dependencies:
ansi-regex "^4.1.0"
strip-ansi@6.0, strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@ -24142,7 +24157,7 @@ wordwrap@^1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@ -24160,15 +24175,6 @@ wrap-ansi@^6.0.1:
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"