Adding baseUrl for GHE auth

This commit is contained in:
Leo Giovanetti
2021-12-03 18:47:02 -03:00
parent 8178b36b5a
commit 71cd64f865
9 changed files with 1349 additions and 8107 deletions
+18
View File
@@ -78,6 +78,24 @@ jobs:
CHANGELOG: ${{ steps.complex_release.outputs.changelog }} CHANGELOG: ${{ steps.complex_release.outputs.changelog }}
run: echo "CHANGELOG" run: echo "CHANGELOG"
# Showcases a more complex configuration, providing a configuration, and specifically referencing owner, repo, from, to tag and base URL
- name: "Complex Configuration with base URL"
id: complex_release_baseurl
uses: ./
with:
configuration: "configs/configuration_complex.json"
owner: "mikepenz"
repo: "release-changelog-builder-action"
fromTag: "v0.0.1"
toTag: "v0.0.3"
baseUrl: "https://corp.globant.com/api/v3"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Echo Complex Configuration With baseUrl Changelog
env:
CHANGELOG: ${{ steps.complex_release_baseurl.outputs.changelog }}
run: echo "CHANGELOG"
# Showcases the capability to generate the changelog for an external repository provided # Showcases the capability to generate the changelog for an external repository provided
- name: "External Repo Configuration" - name: "External Repo Configuration"
id: external_changelog id: external_changelog
+1
View File
@@ -255,6 +255,7 @@ For advanced use cases additional settings can be provided to the action
| `toTag` | Defines until which tag the changelog will consider merged pull requests | | `toTag` | Defines until which tag the changelog will consider merged pull requests |
| `path` | Allows to specify an alternative sub directory, to use as base | | `path` | Allows to specify an alternative sub directory, to use as base |
| `token` | Alternative config to specify token. You should prefer `env.GITHUB_TOKEN` instead though | | `token` | Alternative config to specify token. You should prefer `env.GITHUB_TOKEN` instead though |
| `baseUrl` | Alternative config to specify base url for GitHub Enterprise authentication. Default value set to `https://api.github.com` |
| `ignorePreReleases` | Allows to ignore pre-releases for changelog generation (E.g. for 1.0.1... 1.0.0-rc02 <- ignore, 1.0.0 <- pick). Only used if `fromTag` was not specified. Default: false | | `ignorePreReleases` | Allows to ignore pre-releases for changelog generation (E.g. for 1.0.1... 1.0.0-rc02 <- ignore, 1.0.0 <- pick). Only used if `fromTag` was not specified. Default: false |
| `failOnError` | Defines if the action will result in a build failure if problems occurred. Default: false | | `failOnError` | Defines if the action will result in a build failure if problems occurred. Default: false |
| `commitMode` | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. Default: false | | `commitMode` | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. Default: false |
+9
View File
@@ -6,6 +6,7 @@ jest.setTimeout(180000)
it('Should match generated changelog (unspecified fromTag)', async () => { it('Should match generated changelog (unspecified fromTag)', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = resolveConfiguration('', 'configs/configuration.json')
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -31,6 +32,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
it('Should match generated changelog (unspecified tags)', async () => { it('Should match generated changelog (unspecified tags)', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = resolveConfiguration('', 'configs/configuration.json')
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -53,6 +55,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
it('Should use empty placeholder', async () => { it('Should use empty placeholder', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = resolveConfiguration('', 'configs/configuration.json')
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -76,6 +79,7 @@ it('Should fill empty placeholders', async () => {
'configs_test/configuration_empty_all_placeholders.json' 'configs_test/configuration_empty_all_placeholders.json'
) )
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -101,6 +105,7 @@ it('Should fill `template` placeholders', async () => {
'configs_test/configuration_empty_all_placeholders.json' 'configs_test/configuration_empty_all_placeholders.json'
) )
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -126,6 +131,7 @@ it('Should fill `template` placeholders, ignore', async () => {
'configs_test/configuration_empty_all_placeholders.json' 'configs_test/configuration_empty_all_placeholders.json'
) )
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -151,6 +157,7 @@ it('Uncategorized category', async () => {
'configs_test/configuration_uncategorized_category.json' 'configs_test/configuration_uncategorized_category.json'
) )
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -176,6 +183,7 @@ it('Verify commit based changelog', async () => {
'configs_test/configuration_commits.json' 'configs_test/configuration_commits.json'
) )
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'mikepenz', 'mikepenz',
@@ -201,6 +209,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
'configs_test/configuration_commits_emoji.json' 'configs_test/configuration_commits_emoji.json'
) )
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
null, null,
'.', '.',
'theapache64', 'theapache64',
+2
View File
@@ -30,6 +30,8 @@ inputs:
description: 'If defined, the changelog will get written to this file. (relative to the checkout dir)' description: 'If defined, the changelog will get written to this file. (relative to the checkout dir)'
token: token:
description: 'Defines the token to use to execute the git API requests with, uses `env.GITHUB_TOKEN` by default' description: 'Defines the token to use to execute the git API requests with, uses `env.GITHUB_TOKEN` by default'
baseUrl:
description: 'Defines the base url for GitHub Enterprise authentication, uses `https://api.github.com` by default'
outputs: outputs:
changelog: changelog:
description: The built release changelog built from the merged pull requests description: The built release changelog built from the merged pull requests
Generated Vendored
+6 -3
View File
@@ -357,6 +357,7 @@ function run() {
const configurationFile = core.getInput('configuration'); const configurationFile = core.getInput('configuration');
const configuration = (0, utils_1.resolveConfiguration)(repositoryPath, configurationFile); const configuration = (0, utils_1.resolveConfiguration)(repositoryPath, configurationFile);
// read in repository inputs // read in repository inputs
const baseUrl = core.getInput('baseUrl');
const token = core.getInput('token'); const token = core.getInput('token');
const owner = core.getInput('owner') || github.context.repo.owner; const owner = core.getInput('owner') || github.context.repo.owner;
const repo = core.getInput('repo') || github.context.repo.repo; const repo = core.getInput('repo') || github.context.repo.repo;
@@ -367,7 +368,7 @@ function run() {
const ignorePreReleases = core.getInput('ignorePreReleases') === 'true'; const ignorePreReleases = core.getInput('ignorePreReleases') === 'true';
const failOnError = core.getInput('failOnError') === 'true'; const failOnError = core.getInput('failOnError') === 'true';
const commitMode = core.getInput('commitMode') === 'true'; const commitMode = core.getInput('commitMode') === 'true';
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(token, repositoryPath, owner, repo, fromTag, toTag, failOnError, ignorePreReleases, commitMode, configuration).build(); const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, failOnError, ignorePreReleases, commitMode, configuration).build();
core.setOutput('changelog', result); core.setOutput('changelog', result);
// write the result in changelog to file if possible // write the result in changelog to file if possible
const outputFile = core.getInput('outputFile'); const outputFile = core.getInput('outputFile');
@@ -765,7 +766,8 @@ const tags_1 = __nccwpck_require__(7532);
const utils_1 = __nccwpck_require__(918); const utils_1 = __nccwpck_require__(918);
const transform_1 = __nccwpck_require__(1644); const transform_1 = __nccwpck_require__(1644);
class ReleaseNotesBuilder { class ReleaseNotesBuilder {
constructor(token, repositoryPath, owner, repo, fromTag, toTag, failOnError, ignorePreReleases, commitMode, configuration) { constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, failOnError, ignorePreReleases, commitMode, configuration) {
this.baseUrl = baseUrl;
this.token = token; this.token = token;
this.repositoryPath = repositoryPath; this.repositoryPath = repositoryPath;
this.owner = owner; this.owner = owner;
@@ -799,7 +801,8 @@ class ReleaseNotesBuilder {
core.endGroup(); core.endGroup();
// load octokit instance // load octokit instance
const octokit = new rest_1.Octokit({ const octokit = new rest_1.Octokit({
auth: `token ${this.token || process.env.GITHUB_TOKEN}` auth: `token ${this.token || process.env.GITHUB_TOKEN}`,
baseUrl: `${this.baseUrl || "https://api.github.com"}`
}); });
// ensure proper from <-> to tag range // ensure proper from <-> to tag range
core.startGroup(`🔖 Resolve tags`); core.startGroup(`🔖 Resolve tags`);
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -6804
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -24,6 +24,7 @@ async function run(): Promise<void> {
) )
// read in repository inputs // read in repository inputs
const baseUrl = core.getInput('baseUrl')
const token = core.getInput('token') const token = core.getInput('token')
const owner = core.getInput('owner') || github.context.repo.owner const owner = core.getInput('owner') || github.context.repo.owner
const repo = core.getInput('repo') || github.context.repo.repo const repo = core.getInput('repo') || github.context.repo.repo
@@ -36,6 +37,7 @@ async function run(): Promise<void> {
const commitMode = core.getInput('commitMode') === 'true' const commitMode = core.getInput('commitMode') === 'true'
const result = await new ReleaseNotesBuilder( const result = await new ReleaseNotesBuilder(
baseUrl,
token, token,
repositoryPath, repositoryPath,
owner, owner,
+3 -1
View File
@@ -8,6 +8,7 @@ import {fillAdditionalPlaceholders} from './transform'
export class ReleaseNotesBuilder { export class ReleaseNotesBuilder {
constructor( constructor(
private baseUrl: string | null,
private token: string | null, private token: string | null,
private repositoryPath: string, private repositoryPath: string,
private owner: string | null, private owner: string | null,
@@ -40,7 +41,8 @@ export class ReleaseNotesBuilder {
// load octokit instance // load octokit instance
const octokit = new Octokit({ const octokit = new Octokit({
auth: `token ${this.token || process.env.GITHUB_TOKEN}` auth: `token ${this.token || process.env.GITHUB_TOKEN}`,
baseUrl: `${this.baseUrl || "https://api.github.com"}`
}) })
// ensure proper from <-> to tag range // ensure proper from <-> to tag range