Skip to content

Commit 75cb5b4

Browse files
committed
K
1 parent 1df4b3e commit 75cb5b4

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

dist/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -754904,44 +754904,44 @@ core.info(`Spreadsheet ID: ${spreadsheetId}`);
754904754904
core.info(`Localization Root: ${localizationRoot}`);
754905754905

754906754906
// Write the Google API key to a file
754907-
const googleApiKeyFilePath = path.join(process.cwd(), 'google-api-key.json');
754907+
const googleApiKeyFilePath = path.join(__dirname, 'google-api-key.json');
754908754908
fs.writeFileSync(googleApiKeyFilePath, JSON.stringify(googleApiKeyJson));
754909754909

754910754910
process.env.GOOGLE_APPLICATION_CREDENTIALS = googleApiKeyFilePath;
754911754911
process.env.SPREADSHEET_ID = spreadsheetId;
754912754912
process.env.LOCALIZATION_ROOT = localizationRoot;
754913754913

754914+
const cleanUp = () => {
754915+
if (fs.existsSync(googleApiKeyFilePath)) {
754916+
fs.unlinkSync(googleApiKeyFilePath);
754917+
}
754918+
};
754919+
754914754920
try {
754915754921
if (action === 'push') {
754916754922
pushMain().then(() => {
754917-
// Clean up the Google API key file
754918-
fs.unlinkSync(googleApiKeyFilePath);
754923+
cleanUp();
754919754924
}).catch((error) => {
754920754925
core.setFailed(`Action failed with error: ${error.message}`);
754921-
// Clean up the Google API key file
754922-
fs.unlinkSync(googleApiKeyFilePath);
754926+
cleanUp();
754923754927
process.exit(1);
754924754928
});
754925754929
} else if (action === 'pull') {
754926754930
pullMain().then(() => {
754927-
// Clean up the Google API key file
754928-
fs.unlinkSync(googleApiKeyFilePath);
754931+
cleanUp();
754929754932
}).catch((error) => {
754930754933
core.setFailed(`Action failed with error: ${error.message}`);
754931-
// Clean up the Google API key file
754932-
fs.unlinkSync(googleApiKeyFilePath);
754934+
cleanUp();
754933754935
process.exit(1);
754934754936
});
754935754937
} else {
754936754938
core.setFailed(`Unknown action: ${action}`);
754937-
// Clean up the Google API key file
754938-
fs.unlinkSync(googleApiKeyFilePath);
754939+
cleanUp();
754939754940
process.exit(1);
754940754941
}
754941754942
} catch (error) {
754942754943
core.setFailed(`Action failed with error: ${error.message}`);
754943-
// Clean up the Google API key file
754944-
fs.unlinkSync(googleApiKeyFilePath);
754944+
cleanUp();
754945754945
process.exit(1);
754946754946
}
754947754947

entrypoint.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,43 @@ core.info(`Spreadsheet ID: ${spreadsheetId}`);
4141
core.info(`Localization Root: ${localizationRoot}`);
4242

4343
// Write the Google API key to a file
44-
const googleApiKeyFilePath = path.join(process.cwd(), 'google-api-key.json');
44+
const googleApiKeyFilePath = path.join(__dirname, 'google-api-key.json');
4545
fs.writeFileSync(googleApiKeyFilePath, JSON.stringify(googleApiKeyJson));
4646

4747
process.env.GOOGLE_APPLICATION_CREDENTIALS = googleApiKeyFilePath;
4848
process.env.SPREADSHEET_ID = spreadsheetId;
4949
process.env.LOCALIZATION_ROOT = localizationRoot;
5050

51+
const cleanUp = () => {
52+
if (fs.existsSync(googleApiKeyFilePath)) {
53+
fs.unlinkSync(googleApiKeyFilePath);
54+
}
55+
};
56+
5157
try {
5258
if (action === 'push') {
5359
pushMain().then(() => {
54-
// Clean up the Google API key file
55-
fs.unlinkSync(googleApiKeyFilePath);
60+
cleanUp();
5661
}).catch((error) => {
5762
core.setFailed(`Action failed with error: ${error.message}`);
58-
// Clean up the Google API key file
59-
fs.unlinkSync(googleApiKeyFilePath);
63+
cleanUp();
6064
process.exit(1);
6165
});
6266
} else if (action === 'pull') {
6367
pullMain().then(() => {
64-
// Clean up the Google API key file
65-
fs.unlinkSync(googleApiKeyFilePath);
68+
cleanUp();
6669
}).catch((error) => {
6770
core.setFailed(`Action failed with error: ${error.message}`);
68-
// Clean up the Google API key file
69-
fs.unlinkSync(googleApiKeyFilePath);
71+
cleanUp();
7072
process.exit(1);
7173
});
7274
} else {
7375
core.setFailed(`Unknown action: ${action}`);
74-
// Clean up the Google API key file
75-
fs.unlinkSync(googleApiKeyFilePath);
76+
cleanUp();
7677
process.exit(1);
7778
}
7879
} catch (error) {
7980
core.setFailed(`Action failed with error: ${error.message}`);
80-
// Clean up the Google API key file
81-
fs.unlinkSync(googleApiKeyFilePath);
81+
cleanUp();
8282
process.exit(1);
8383
}

0 commit comments

Comments
 (0)