Skip to content

Commit 6b96943

Browse files
committed
fix: use project ID for API calls if available
1 parent bc32806 commit 6b96943

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/get-project-context.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import urlJoin from "url-join";
22

33
import getProjectPath from "./get-project-path.js";
4+
import getProjectId from "./get-project-id.js";
45

56
export default (context, gitlabUrl, gitlabApiUrl, repositoryUrl) => {
7+
const projectId = getProjectId(context);
68
const projectPath = getProjectPath(context, gitlabUrl, repositoryUrl);
79
const encodedProjectPath = encodeURIComponent(projectPath);
8-
const projectApiUrl = urlJoin(gitlabApiUrl, `/projects/${encodedProjectPath}`);
10+
const projectApiUrl = urlJoin(gitlabApiUrl, `/projects/${projectId ?? encodedProjectPath}`);
911
return {
1012
projectPath,
1113
encodedProjectPath,

lib/get-project-id.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default ({ envCi: { service } = {}, env: { CI_PROJECT_ID } }) =>
2+
service === "gitlab" && CI_PROJECT_ID
3+
? CI_PROJECT_ID
4+
: null;

0 commit comments

Comments
 (0)