-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add raw CI env vars to log (#216)
- Loading branch information
Showing
7 changed files
with
107 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 25 additions & 14 deletions
39
packages/bundlemon/lib/main/utils/ci/providers/circleCI.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
import type { Provider } from '../types'; | ||
import { getEnvVar } from '../../utils'; | ||
import { envVarsListToObject, getEnvVar } from '../../utils'; | ||
|
||
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables | ||
|
||
const provider: Provider = { | ||
isItMe: getEnvVar('CIRCLECI') === 'true', | ||
getVars: () => ({ | ||
ci: true, | ||
provider: 'circleci', | ||
owner: getEnvVar('CIRCLE_PROJECT_USERNAME'), | ||
repo: getEnvVar('CIRCLE_PROJECT_REPONAME'), | ||
branch: getEnvVar('CIRCLE_BRANCH'), | ||
commitSha: getEnvVar('CIRCLE_SHA1'), | ||
// target branch not available in CircleCI | ||
// https://ideas.circleci.com/cloud-feature-requests/p/provide-env-variable-for-branch-name-targeted-by-pull-request | ||
// use CI_TARGET_BRANCH to override | ||
targetBranch: undefined, | ||
prNumber: getEnvVar('CIRCLE_PULL_REQUEST')?.split('/').pop(), | ||
}), | ||
getVars: () => { | ||
const raw = envVarsListToObject([ | ||
'CIRCLE_PROJECT_USERNAME', | ||
'CIRCLE_PROJECT_REPONAME', | ||
'CIRCLE_BRANCH', | ||
'CIRCLE_SHA1', | ||
'CIRCLE_PULL_REQUEST', | ||
] as const); | ||
|
||
return { | ||
raw, | ||
ci: true, | ||
provider: 'circleci', | ||
owner: raw.CIRCLE_PROJECT_USERNAME, | ||
repo: raw.CIRCLE_PROJECT_REPONAME, | ||
branch: raw.CIRCLE_BRANCH, | ||
commitSha: raw.CIRCLE_SHA1, | ||
// target branch not available in CircleCI | ||
// https://ideas.circleci.com/cloud-feature-requests/p/provide-env-variable-for-branch-name-targeted-by-pull-request | ||
// use CI_TARGET_BRANCH to override | ||
targetBranch: undefined, | ||
prNumber: raw.CIRCLE_PULL_REQUEST?.split('/').pop(), | ||
}; | ||
}, | ||
}; | ||
|
||
export default provider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters