Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fallback GITLAB_HOST to CI_SERVER_URL #113

Merged
merged 5 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: use CI_SERVER_URL constantly
  • Loading branch information
JounQin committed Aug 3, 2023
commit 44e045a6126e38a1527a05847dcf4475598227a3
15 changes: 2 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ export const createApi = (gitlabToken?: string) => {
}
}

const {
GITLAB_TOKEN,
CI_SERVER_PROTOCOL,
CI_SERVER_HOST,
} = process.env

const token = gitlabToken || GITLAB_TOKEN
const token = gitlabToken || process.env.GITLAB_TOKEN

let tokenType: 'jobToken' | 'oauthToken' | 'token' = 'token'

Expand All @@ -42,13 +36,8 @@ export const createApi = (gitlabToken?: string) => {
break
}

const host = process.env.GITLAB_HOST ??
(CI_SERVER_PROTOCOL && CI_SERVER_HOST)
? `${CI_SERVER_PROTOCOL}:https://${CI_SERVER_HOST}`
: 'https://gitlab.com'

return new Gitlab({
host,
host: process.env.GITLAB_HOST ?? process.env.CI_SERVER_URL,
[tokenType]: token,
})
}
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { createApi } from './index.js'
export const main = async ({
published,
onlyChangesets,
}: MainCommandOptions = {}) => {
}: // eslint-disable-next-line sonarjs/cognitive-complexity
MainCommandOptions = {}) => {
const {
CI,
CI_PROJECT_PATH,
Expand Down
Loading