From d543d2d8da0fef897ddbd04365b2431c6c84db9a Mon Sep 17 00:00:00 2001 From: Jaspal Puri Date: Tue, 7 Feb 2023 13:47:49 +0000 Subject: [PATCH 1/3] Enabling use on github enterprise --- README.md | 16 ++++++++++++++++ action.yml | 6 +++++- src/install.ts | 5 +++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2a12a9a..0b0d654 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,22 @@ where 2. `${{ secret.ALLURE_TOKEN }}` is the personal API token created in your profile of Allure TestOps. You need to save API token under `/settings/secrets/actions` as a secret `ALLURE_TOKEN` in your GitHub repository and use it as the reference to the created secret – `${{ secret.ALLURE_TOKEN }}`. Having this parameter saved as plain text in the workflow is a bad-bad-bad idea. 3. is the ID of a project to which you are sending the test results. +### For Github Enterprise +Depending on the scope of the Github token provided by default to the action, two tokens may be required for this action: + +```yaml + - uses: allure-framework/setup-allurectl@v1 + with: + allure-endpoint: https://ALURE_TESTOPS_URL + allure-token: ${{ secret.ALLURE_TOKEN }} + allure-project-id: + github-token: ${{ secret.GITHUB_TOKEN }} + github-workflow-token: ${{ secret.GITHUB_WORKFLOW_TOKEN }} +``` +where +1. `${{ secret.GITHUB_TOKEN }}` allows access to public Github +2. `${{ secret.GITHUB_WORKFLOW_TOKEN }}` allows access to information from the current workflow in Github Enterprise + ### Use allurectl to upload the test results to Allure TestOps ```yaml diff --git a/action.yml b/action.yml index 42962a2..b2ccbbb 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,11 @@ inputs: description: 'The ID of a project on the Allure TestOps side to which allurectl must send the test results' required: false github-token: - description: The GitHub token used to create an authenticated client + description: 'The GitHub token used to create an authenticated client to call https://api.github.com.' + default: ${{ github.token }} + required: false + github-workflow-token: + description: 'The GitHub token used to create an authenticated client to access Workflow metadata.' default: ${{ github.token }} required: false runs: diff --git a/src/install.ts b/src/install.ts index dd0933a..ef2e569 100644 --- a/src/install.ts +++ b/src/install.ts @@ -70,7 +70,7 @@ export async function testTool(cmd: string, args: string[]) { } export async function setUpTool() { - const github_token = core.getInput('github-token', {required: true}) + const github_token = core.getInput('github-workflow-token', {required: true}) const client: ClientType = github.getOctokit(github_token) const owner = github.context.repo.owner @@ -91,7 +91,8 @@ export async function setUpTool() { export async function getVersion(inputVersion: string): Promise { const github_token = core.getInput('github-token', {required: true}) - const client: ClientType = github.getOctokit(github_token) + + const client: ClientType = github.getOctokit(github_token, {baseUrl: "https://api.github.com"}) if (inputVersion && inputVersion !== 'latest') { const response = await client.rest.repos.getReleaseByTag({ From 3373f2739d42889440b16b536ca48452aabe2241 Mon Sep 17 00:00:00 2001 From: Jaspal Puri Date: Tue, 7 Feb 2023 13:58:18 +0000 Subject: [PATCH 2/3] Updating readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b0d654..afd343b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ where 3. is the ID of a project to which you are sending the test results. ### For Github Enterprise -Depending on the scope of the Github token provided by default to the action, two tokens may be required for this action: +Depending on the scope of the Github token provided by default to the workflow, two tokens may be required for this action: ```yaml - uses: allure-framework/setup-allurectl@v1 From 495c0120f9a93fed21f8a5831907c8a53181cba8 Mon Sep 17 00:00:00 2001 From: Jaspal Puri Date: Tue, 7 Feb 2023 15:49:42 +0000 Subject: [PATCH 3/3] Run formatter --- src/install.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/install.ts b/src/install.ts index ef2e569..489708f 100644 --- a/src/install.ts +++ b/src/install.ts @@ -92,7 +92,9 @@ export async function setUpTool() { export async function getVersion(inputVersion: string): Promise { const github_token = core.getInput('github-token', {required: true}) - const client: ClientType = github.getOctokit(github_token, {baseUrl: "https://api.github.com"}) + const client: ClientType = github.getOctokit(github_token, { + baseUrl: 'https://api.github.com' + }) if (inputVersion && inputVersion !== 'latest') { const response = await client.rest.repos.getReleaseByTag({