Skip to content

Commit ed3e47f

Browse files
authored
fix: gitlab & bitbucket actions (#430)
* chore: move defaults to code * fix: gitlab & bitbucket actions
1 parent 5dd7b65 commit ed3e47f

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ inputs:
2626
required: false
2727
commit-message:
2828
description: "Commit message"
29-
default: "feat: update translations via @lingodotdev"
3029
required: false
3130
pull-request-title:
3231
description: "Pull request title"
33-
default: "feat: update translations via @lingodotdev"
3432
required: false
3533
working-directory:
3634
description: "Working directory"
37-
default: "."
3835
required: false

action/src/flows/in-branch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export class InBranchFlow extends IntegrationFlow {
6363
execSync(`git config user.name "${gitConfig.userName}"`);
6464
execSync(`git config user.email "${gitConfig.userEmail}"`);
6565

66+
// perform platform-specific configuration before fetching or pushing to the remote
67+
this.platformKit?.gitConfig();
68+
6669
execSync(`git fetch origin ${baseBranchName}`, { stdio: "inherit" });
6770
execSync(`git checkout ${baseBranchName} --`, { stdio: "inherit" });
6871

@@ -73,8 +76,6 @@ export class InBranchFlow extends IntegrationFlow {
7376
return false;
7477
}
7578

76-
this.platformKit?.gitConfig();
77-
7879
const workingDir = path.resolve(process.cwd(), this.platformKit.config.workingDir);
7980
if (workingDir !== process.cwd()) {
8081
this.ora.info(`Changing to working directory: ${this.platformKit.config.workingDir}`);

action/src/platforms/_base.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Z from "zod";
22

3+
const defaultMessage = "feat: update translations via @lingodotdev";
4+
35
interface BasePlatformConfig {
46
baseBranchName: string;
57
repositoryOwner: string;
@@ -27,17 +29,17 @@ export abstract class PlatformKit<PlatformConfig extends BasePlatformConfig = Ba
2729
const env = Z.object({
2830
LINGODOTDEV_API_KEY: Z.string(),
2931
LINGODOTDEV_PULL_REQUEST: Z.preprocess((val) => val === "true" || val === true, Z.boolean()),
30-
LINGODOTDEV_COMMIT_MESSAGE: Z.string(),
31-
LINGODOTDEV_PULL_REQUEST_TITLE: Z.string(),
32-
LINGODOTDEV_WORKING_DIRECTORY: Z.string().optional().default("."),
32+
LINGODOTDEV_COMMIT_MESSAGE: Z.string().optional(),
33+
LINGODOTDEV_PULL_REQUEST_TITLE: Z.string().optional(),
34+
LINGODOTDEV_WORKING_DIRECTORY: Z.string().optional(),
3335
}).parse(process.env);
3436

3537
return {
3638
replexicaApiKey: env.LINGODOTDEV_API_KEY,
3739
isPullRequestMode: env.LINGODOTDEV_PULL_REQUEST,
38-
commitMessage: env.LINGODOTDEV_COMMIT_MESSAGE,
39-
pullRequestTitle: env.LINGODOTDEV_PULL_REQUEST_TITLE,
40-
workingDir: env.LINGODOTDEV_WORKING_DIRECTORY,
40+
commitMessage: env.LINGODOTDEV_COMMIT_MESSAGE || defaultMessage,
41+
pullRequestTitle: env.LINGODOTDEV_PULL_REQUEST_TITLE || defaultMessage,
42+
workingDir: env.LINGODOTDEV_WORKING_DIRECTORY || ".",
4143
};
4244
}
4345
}

action/src/platforms/bitbucket.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ export class BitbucketPlatformKit extends PlatformKit<BitbucketConfig> {
9292
}
9393

9494
async gitConfig() {
95-
execSync("git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://host.docker.internal:29418/");
95+
execSync("git config --unset http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy", {
96+
stdio: "inherit",
97+
});
98+
execSync("git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://host.docker.internal:29418/", {
99+
stdio: "inherit",
100+
});
96101
}
97102

98103
get platformConfig() {

action/src/platforms/gitlab.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,10 @@ export class GitlabPlatformKit extends PlatformKit {
9191
}
9292

9393
gitConfig(): Promise<void> | void {
94-
const url = `https://gitlab-ci-token:${this.platformConfig.glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;
94+
const url = `https://oauth2:${this.platformConfig.glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;
9595
execSync(`git remote set-url origin ${url}`, {
9696
stdio: "inherit",
9797
});
98-
execSync(`git checkout -b ${this.platformConfig.baseBranchName}`, {
99-
stdio: "inherit",
100-
});
10198
}
10299

103100
buildPullRequestUrl(pullRequestNumber: number): string {

0 commit comments

Comments
 (0)