Skip to content

Commit

Permalink
feat: Add support for Github Enterprise (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
feliperoveran committed Dec 15, 2021
1 parent 60ee532 commit 579fb11
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ The action works without configuration, however you can provide options for cust
# merge commit, and it's easy to commit this by mistake. Enable this option
# to also validate the commit message for one commit PRs.
validateSingleCommit: true
# If you use Github Enterprise, you can set this to the URL of your server
githubBaseUrl: https://github.myorg.com/api/v3
```

## Event triggers
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ inputs:
validateSingleCommit:
description: "When using \"Squash and merge\" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit, and it's easy to commit this by mistake. Enable this option to also validate the commit message for one commit PRs."
required: false
githubBaseUrl:
description: "If you use Github Enterprise, you can set this to the URL of your server (e.g. https://github.myorg.com/api/v3)"
required: false
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ const validatePrTitle = require('./validatePrTitle');

module.exports = async function run() {
try {
const client = github.getOctokit(process.env.GITHUB_TOKEN);
const {
types,
scopes,
requireScope,
wip,
subjectPattern,
subjectPatternError,
validateSingleCommit
validateSingleCommit,
githubBaseUrl
} = parseConfig();

const client = github.getOctokit(process.env.GITHUB_TOKEN, {
baseUrl: githubBaseUrl
});

const contextPullRequest = github.context.payload.pull_request;
if (!contextPullRequest) {
throw new Error(
Expand Down
8 changes: 7 additions & 1 deletion src/parseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ module.exports = function parseConfig() {
);
}

let githubBaseUrl;
if (process.env.INPUT_GITHUBBASEURL) {
githubBaseUrl = ConfigParser.parseString(process.env.INPUT_GITHUBBASEURL);
}

return {
types,
scopes,
requireScope,
wip,
subjectPattern,
subjectPatternError,
validateSingleCommit
validateSingleCommit,
githubBaseUrl
};
};

0 comments on commit 579fb11

Please sign in to comment.