diff --git a/README.md b/README.md index 2a12a9a..afd343b 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 workflow, 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..489708f 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,10 @@ 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({