Skip to content

Commit

Permalink
fix: run safe-directory on /github/workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasv314 authored and codfish committed Nov 9, 2023
1 parent 7f2510c commit 3e26d45
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ const installPackages = (packages) => {
}
};

/**
* Sets the github workspace as a safe directory in the global git config.
*
* @returns {object} - Response from `child_process.spawnSync()`.
*/
const setGitConfigSafeDirectory = () => {
try {
core.debug(`Enabling github workspace as a git safe directory`);
const spawn = childProcess.spawnSync('git', [
'config',
'--global',
'--add',
'safe.directory',
process.env.GITHUB_WORKSPACE,
]);
if (spawn.status !== 0) {
throw new Error(spawn.stderr);
}
core.debug(`Set ${process.env.GITHUB_WORKSPACE} as a safe directory.`);
return spawn;
} catch (err) {
core.debug(`Error setting ${process.env.GITHUB_WORKSPACE} as a safe directory.`);
throw err;
}
};

/**
* Run semantic-release.
*
Expand Down Expand Up @@ -67,6 +93,8 @@ async function run() {
core.debug(`repository-url input: ${repositoryUrl}`);
core.debug(`tag-format input: ${tagFormat}`);

setGitConfigSafeDirectory();

// install additional plugins/configurations
if (extendsInput) {
additionalPackages.push(...arrify(extendsInput));
Expand Down

0 comments on commit 3e26d45

Please sign in to comment.