Skip to content

Commit bafbef5

Browse files
authored
fix: use correct env var to detect gitlab CI for OIDC (#6938)
## What's the problem this PR addresses? When #6898 added support for OIDC publishing, it copied the getOidcToken function from npm's implementation. However, `ciInfo` was directly replaced with `process.env`, which coincidentally worked fine for GitHub Actions (both the `ciInfo` constant and the environment variable are named `GITHUB_ACTIONS`), but not for GitLab (the `ciInfo` constant is `GITLAB`, but the actual env var is `GITLAB_CI`). ## How did you fix it? Replaced `process.env.GITLAB` with `process.env.GITLAB_CI` ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent eda7540 commit bafbef5

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

.yarn/versions/c5da5cd9.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/core": patch
4+
"@yarnpkg/plugin-npm": patch
5+
"@yarnpkg/plugin-npm-cli": patch
6+
7+
declined:
8+
- "@yarnpkg/plugin-catalog"
9+
- "@yarnpkg/plugin-compat"
10+
- "@yarnpkg/plugin-constraints"
11+
- "@yarnpkg/plugin-dlx"
12+
- "@yarnpkg/plugin-essentials"
13+
- "@yarnpkg/plugin-exec"
14+
- "@yarnpkg/plugin-file"
15+
- "@yarnpkg/plugin-git"
16+
- "@yarnpkg/plugin-github"
17+
- "@yarnpkg/plugin-http"
18+
- "@yarnpkg/plugin-init"
19+
- "@yarnpkg/plugin-interactive-tools"
20+
- "@yarnpkg/plugin-jsr"
21+
- "@yarnpkg/plugin-link"
22+
- "@yarnpkg/plugin-nm"
23+
- "@yarnpkg/plugin-pack"
24+
- "@yarnpkg/plugin-patch"
25+
- "@yarnpkg/plugin-pnp"
26+
- "@yarnpkg/plugin-pnpm"
27+
- "@yarnpkg/plugin-stage"
28+
- "@yarnpkg/plugin-typescript"
29+
- "@yarnpkg/plugin-version"
30+
- "@yarnpkg/plugin-workspace-tools"
31+
- "@yarnpkg/builder"
32+
- "@yarnpkg/doctor"
33+
- "@yarnpkg/extensions"
34+
- "@yarnpkg/nm"
35+
- "@yarnpkg/pnpify"
36+
- "@yarnpkg/sdks"

packages/plugin-npm-cli/sources/commands/npm/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default class NpmPublishCommand extends BaseCommand {
166166
ident,
167167
otp: this.otp,
168168
jsonResponse: true,
169-
allowOidc: Boolean(process.env.CI && (process.env.GITHUB_ACTIONS || process.env.GITLAB)),
169+
allowOidc: Boolean(process.env.CI && (process.env.GITHUB_ACTIONS || process.env.GITLAB_CI)),
170170
});
171171
}
172172

packages/plugin-npm/sources/npmHttpUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ function getOtpHeaders(otp: string) {
593593
async function getOidcToken(registry: string, {configuration, ident}: {configuration: Configuration, ident: Ident}): Promise<string | null> {
594594
let idToken: string | null = null;
595595

596-
if (process.env.GITLAB) {
596+
if (process.env.GITLAB_CI) {
597597
idToken = process.env.NPM_ID_TOKEN || null;
598598
} else if (process.env.GITHUB_ACTIONS) {
599599
if (!(process.env.ACTIONS_ID_TOKEN_REQUEST_URL && process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN))

0 commit comments

Comments
 (0)