From d319f8f5b55ea40916b869b2ca9ae2f059c60abf Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 17 Nov 2023 11:59:30 -0500 Subject: [PATCH 1/2] Avoid setting `baseUrl` to undefined when input is not provided --- .github/workflows/integration.yml | 75 +++++++++++++++++++++++++++++++ dist/index.js | 8 +++- src/main.ts | 9 +++- 3 files changed, 88 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 603d5ad90..13494d988 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -248,3 +248,78 @@ jobs: done <<< "$tests" echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY + + test-base-url: + name: 'Integration test: base-url option' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/install-dependencies + + - id: base-url-default + name: API URL with base-url not set + uses: ./ + with: + script: | + const endpoint = github.request.endpoint + return endpoint({}).url + result-encoding: string + + - id: base-url-default-graphql + name: GraphQL URL with base-url not set + uses: ./ + with: + script: | + const endpoint = github.request.endpoint + return endpoint({url: "/graphql"}).url + result-encoding: string + + - id: base-url-set + name: API URL with base-url set + uses: ./ + with: + base-url: https://my.github-enterprise-server.com/api/v3 + script: | + const endpoint = github.request.endpoint + return endpoint({}).url + result-encoding: string + + - id: base-url-set-graphql + name: GraphQL URL with base-url set + uses: ./ + with: + base-url: https://my.github-enterprise-server.com/api/v3 + script: | + const endpoint = github.request.endpoint + return endpoint({url: "/graphql"}).url + result-encoding: string + + - run: | + echo "- Validating API URL default" + expected="https://api.github.com/" + actual="${{steps.base-url-default.outputs.result}}" + if [[ "$expected" != "$actual" ]]; then + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" + exit 1 + fi + echo "- Validating GraphQL URL default" + expected="https://api.github.com/graphql" + actual="${{steps.base-url-default-graphql.outputs.result}}" + if [[ "$expected" != "$actual" ]]; then + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" + exit 1 + fi + echo "- Validating base-url set to a value" + expected="https://my.github-enterprise-server.com/api/v3/" + actual="${{steps.base-url-set.outputs.result}}" + if [[ "$expected" != "$actual" ]]; then + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" + exit 1 + fi + echo "- Validating GraphQL URL with base-url set to a value" + expected="https://my.github-enterprise-server.com/api/v3/graphql" + actual="${{steps.base-url-set-graphql.outputs.result}}" + if [[ "$expected" != "$actual" ]]; then + echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual" + exit 1 + fi diff --git a/dist/index.js b/dist/index.js index db5b5fa91..98846689d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35509,9 +35509,13 @@ async function main() { userAgent: userAgent || undefined, previews: previews ? previews.split(',') : undefined, retry: retryOpts, - request: requestOpts, - baseUrl: baseUrl || undefined + request: requestOpts }; + // Setting `baseUrl` to undefined will prevent the default value from being used + // https://github.com/actions/github-script/issues/436 + if (baseUrl) { + opts.baseUrl = baseUrl; + } const github = (0,lib_github.getOctokit)(token, opts, plugin_retry_dist_node.retry, dist_node.requestLog); const script = core.getInput('script', { required: true }); // Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors. diff --git a/src/main.ts b/src/main.ts index 965515156..81df4f0e1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -44,8 +44,13 @@ async function main(): Promise { userAgent: userAgent || undefined, previews: previews ? previews.split(',') : undefined, retry: retryOpts, - request: requestOpts, - baseUrl: baseUrl || undefined + request: requestOpts + } + + // Setting `baseUrl` to undefined will prevent the default value from being used + // https://github.com/actions/github-script/issues/436 + if (baseUrl) { + opts.baseUrl = baseUrl } const github = getOctokit(token, opts, retry, requestLog) From b7fb2001b410c9390cbe9e2c7d5cab7eefb7b29c Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 17 Nov 2023 14:15:20 -0500 Subject: [PATCH 2/2] Update version to 7.0.1 --- package-lock.json | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e991f53c7..4b8d91859 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "github-script", - "version": "7.0.0", + "version": "7.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "github-script", - "version": "7.0.0", + "version": "7.0.1", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", diff --git a/package.json b/package.json index 6b5f7e7e4..b3033b703 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "github-script", "description": "A GitHub action for executing a simple script", - "version": "7.0.0", + "version": "7.0.1", "author": "GitHub", "license": "MIT", "main": "dist/index.js", @@ -64,4 +64,4 @@ "ts-jest": "^29.1.1", "typescript": "^5.2.2" } -} +} \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy