Skip to content

Commit 1725692

Browse files
authored
feat: add an option to automatically push commits in action (#153)
* add isAutopush iotion * fix autoPush action
1 parent ffd0416 commit 1725692

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ inputs:
1919
required: false
2020
description: 'A comma separated list of languages to exclude'
2121
default: ''
22+
AUTO_PUSH:
23+
required: false
24+
description: 'Whether automatically push generated files to desired branch'
25+
default: true
2226

2327
runs:
2428
using: 'node16'

src/app.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const action = async () => {
4242
core.info(`UTC offset: ${utcOffset}`);
4343
const exclude = core.getInput('EXCLUDE', {required: false}).split(',');
4444
core.info(`Excluded languages: ${exclude}`);
45+
const isAutoPush = core.getInput('AUTO_PUSH', {required: false});
46+
core.info(`You ${isAutoPush ? 'have' : "haven't"} set automatically push commits`);
47+
4548
try {
4649
// Remove old output
4750
core.info(`Remove old cards...`);
@@ -95,18 +98,20 @@ const action = async () => {
9598
}
9699

97100
// Commit changes
98-
core.info(`Commit file...`);
99-
let retry = 0;
100-
const maxRetry = 3;
101-
while (retry < maxRetry) {
102-
retry += 1;
103-
try {
104-
await commitFile();
105-
} catch (error) {
106-
if (retry == maxRetry) {
107-
throw error;
101+
if (isAutoPush) {
102+
core.info(`Commit file...`);
103+
let retry = 0;
104+
const maxRetry = 3;
105+
while (retry < maxRetry) {
106+
retry += 1;
107+
try {
108+
await commitFile();
109+
} catch (error) {
110+
if (retry == maxRetry) {
111+
throw error;
112+
}
113+
core.warning(`Commit failed. Retry...`);
108114
}
109-
core.warning(`Commit failed. Retry...`);
110115
}
111116
}
112117
} catch (error: any) {

0 commit comments

Comments
 (0)