Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the optional ability to switch directories #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ inputs:
description: "Do not perform tagging, just calculate next version and changelog, then exit."
required: false
default: "false"
repo_path:
description: "Path relative to $GITHUB_WORKSPACE that contains the cloned repository."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update the doc in the README (with some info as to when you'd want to do that)?

required: false

runs:
using: "node12"
Expand Down
11 changes: 11 additions & 0 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,23 @@ export default async function main() {
const dryRun = core.getInput('dry_run');
const customReleaseRules = core.getInput('custom_release_rules');
const shouldFetchAllTags = core.getInput('fetch_all_tags');
const repoPath = core.getInput('repo_path');

let mappedReleaseRules;
if (customReleaseRules) {
mappedReleaseRules = mapCustomReleaseRules(customReleaseRules);
}

if (repoPath) {
try {
const originDirectory = process.cwd();
process.chdir(repoPath);
console.log('Changed directory from ' + originDirectory + ' to ' + process.cwd());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('Changed directory from ' + originDirectory + ' to ' + process.cwd());
core.info(`Changed directory from ${originDirectory} to ${process.cwd()}`);

} catch (err) {
console.log('Error encountered when changing directory: ' + err);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fail the workflow if the chdir fails, otherwise it might lead to unexpected behaviors

}
}

const { GITHUB_REF, GITHUB_SHA } = process.env;

if (!GITHUB_REF) {
Expand Down