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

feat: add support for Github Enterprise #145

Merged
merged 1 commit into from
Dec 15, 2021
Merged
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
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
};
};