Skip to content

Commit 4ce0ea5

Browse files
authored
feat(action): process commits by this action (#511)
If you have a complex CI/CD setup you may want to run the action even on commits by this action. It will still result in no changes in most cases, but it will still check for changes.
1 parent 10534c7 commit 4ce0ea5

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runs:
1515
LINGODOTDEV_COMMIT_MESSAGE: ${{ inputs.commit-message }}
1616
LINGODOTDEV_PULL_REQUEST_TITLE: ${{ inputs.pull-request-title }}
1717
LINGODOTDEV_WORKING_DIRECTORY: ${{ inputs.working-directory }}
18-
18+
LINGODOTDEV_PROCESS_OWN_COMMITS: ${{ inputs.process-own-commits }}
1919
inputs:
2020
api-key:
2121
description: "Lingo.dev Platform API Key"
@@ -33,3 +33,6 @@ inputs:
3333
working-directory:
3434
description: "Working directory"
3535
required: false
36+
process-own-commits:
37+
description: "Process commits made by this action"
38+
required: false

action/src/flows/in-branch.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class InBranchFlow extends IntegrationFlow {
5555
}
5656

5757
private configureGit() {
58+
const { processOwnCommits } = this.platformKit.config;
5859
const { baseBranchName } = this.platformKit.platformConfig;
5960

6061
this.ora.info(`Current working directory:`);
@@ -72,14 +73,16 @@ export class InBranchFlow extends IntegrationFlow {
7273
execSync(`git fetch origin ${baseBranchName}`, { stdio: "inherit" });
7374
execSync(`git checkout ${baseBranchName} --`, { stdio: "inherit" });
7475

75-
const currentAuthor = `${gitConfig.userName} <${gitConfig.userEmail}>`;
76-
const authorOfLastCommit = execSync(`git log -1 --pretty=format:'%an <%ae>'`).toString();
77-
if (authorOfLastCommit === currentAuthor) {
78-
this.ora.warn(`The action will not run on commits by ${currentAuthor}`);
79-
this.ora.warn(
80-
`The last commit was already made by this action. Running this action again will not change anything.`,
81-
);
82-
return false;
76+
if (!processOwnCommits) {
77+
const currentAuthor = `${gitConfig.userName} <${gitConfig.userEmail}>`;
78+
const authorOfLastCommit = execSync(`git log -1 --pretty=format:'%an <%ae>'`).toString();
79+
if (authorOfLastCommit === currentAuthor) {
80+
this.ora.warn(`The action will not run on commits by ${currentAuthor}`);
81+
this.ora.warn(
82+
`The last commit was already made by this action. Running this action again will not change anything.`,
83+
);
84+
return false;
85+
}
8386
}
8487

8588
const workingDir = path.resolve(process.cwd(), this.platformKit.config.workingDir);

action/src/platforms/_base.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export abstract class PlatformKit<PlatformConfig extends BasePlatformConfig = Ba
3232
LINGODOTDEV_COMMIT_MESSAGE: Z.string().optional(),
3333
LINGODOTDEV_PULL_REQUEST_TITLE: Z.string().optional(),
3434
LINGODOTDEV_WORKING_DIRECTORY: Z.string().optional(),
35+
LINGODOTDEV_PROCESS_OWN_COMMITS: Z.preprocess((val) => val === "true" || val === true, Z.boolean()).optional(),
3536
}).parse(process.env);
3637

3738
return {
@@ -40,6 +41,7 @@ export abstract class PlatformKit<PlatformConfig extends BasePlatformConfig = Ba
4041
commitMessage: env.LINGODOTDEV_COMMIT_MESSAGE || defaultMessage,
4142
pullRequestTitle: env.LINGODOTDEV_PULL_REQUEST_TITLE || defaultMessage,
4243
workingDir: env.LINGODOTDEV_WORKING_DIRECTORY || ".",
44+
processOwnCommits: env.LINGODOTDEV_PROCESS_OWN_COMMITS || false,
4345
};
4446
}
4547
}

packages/cli/src/cli/cmd/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default new Command()
6060
validateParams(i18nConfig, flags);
6161
ora.succeed("Localization configuration is valid");
6262

63-
ora.start("Connecting to Replexica Localization Engine...");
63+
ora.start("Connecting to Lingo.dev Localization Engine...");
6464
const auth = await validateAuth(settings);
6565
ora.succeed(`Authenticated as ${auth.email}`);
6666

0 commit comments

Comments
 (0)