Skip to content

Commit

Permalink
feat: add domain url option for private repos (#21)
Browse files Browse the repository at this point in the history
* Implemented domain URL for private repos

* lint improvements
  • Loading branch information
jalexispoveda committed Oct 31, 2023
1 parent c0f5c67 commit b900eee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/bumper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = async (
preReleaseId,
commitMessageToUse,
type,
releaseCommitMessageRegex) => {
releaseCommitMessageRegex,
repoDomain) => {
const token = process.env.GITHUB_TOKEN;
// eslint-disable-next-line security/detect-non-literal-require
const gitEvents = process.env.GITHUB_EVENT_PATH ? require(process.env.GITHUB_EVENT_PATH) : {};
Expand Down Expand Up @@ -109,7 +110,7 @@ module.exports = async (
// eslint-disable-next-line security/detect-non-literal-fs-filename
await promises.writeFile(pathToDocument, newContent);
logInfo('New project file written');
await commitChanges(newVersion, skipCommit, skipTag, skipPush, commitMessageToUse);
await commitChanges(newVersion, skipCommit, skipTag, skipPush, commitMessageToUse, repoDomain);
logInfo('Changes committed');
return true;
};
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const { exitSuccess, logError, exitFailure } = require('./utils');
const commitMessageToUse = core.getInput('commit-message');
const releaseCommitMessageRegex = core.getInput('release-commit-message-regex');
const type = core.getInput('type');
const repoDomain = core.getInput('repository-domain');

const wasBumped = await bumpVersion(tagPrefix,
minorWording,
majorWording,
Expand All @@ -31,7 +33,8 @@ const { exitSuccess, logError, exitFailure } = require('./utils');
preReleaseId,
commitMessageToUse,
type,
releaseCommitMessageRegex || commitMessageToUse);
releaseCommitMessageRegex || commitMessageToUse,
repoDomain);
if (wasBumped) {
core.setOutput('wasBumped', wasBumped);
exitSuccess('Version bumped!');
Expand Down
12 changes: 10 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async function setGitConfigs() {
await runInWorkspace('git', ['fetch']);
}

async function commitChanges(newVersion, skipCommit, skipTag, skipPush, commitMessageToUse) {
async function commitChanges(newVersion, skipCommit, skipTag, skipPush, commitMessageToUse, repoDomain) {
try {
// to support "actions/checkout@v1"
if (!skipCommit) {
Expand All @@ -343,7 +343,15 @@ async function commitChanges(newVersion, skipCommit, skipTag, skipPush, commitMe
);
}

const remoteRepo = `https://${process.env.GITHUB_ACTOR}:${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
//In case there's a private domain
let repoUrlDomain = 'github.com';

if (repoDomain) {
//Removed https
repoUrlDomain = repoDomain.replace(/^https?\:\/\//i, '');
}

const remoteRepo = `https://${process.env.GITHUB_ACTOR}:${process.env.GITHUB_TOKEN}@${repoUrlDomain}/${process.env.GITHUB_REPOSITORY}.git`;
if (!skipTag) {
await runInWorkspace('git', ['tag', newVersion]);
if (!skipPush) {
Expand Down

0 comments on commit b900eee

Please sign in to comment.