diff --git a/src/artifacts-helper/NOTES.md b/src/artifacts-helper/NOTES.md index 2dfd1e1..b440541 100644 --- a/src/artifacts-helper/NOTES.md +++ b/src/artifacts-helper/NOTES.md @@ -38,6 +38,12 @@ pip install --index-url https://pkgs.dev.azure.com//_pa When the feed URL is an Azure Artifacts feed pip will use the keyring helper to provide the credentials needed to download the package. +## GitHub Actions / Codespaces Prebuild Support + +**Version 3.0.1+**: The shim scripts now detect when running in a GitHub Actions environment (during Codespaces prebuild) by checking for the `ACTIONS_ID_TOKEN_REQUEST_URL` environment variable. When this variable is set, the shims bypass all Azure DevOps authentication setup and execute the real commands directly. + +This ensures any custom scripting in place during Codespaces build process will work as expected. This feature can only be used at Codespaces runtime as it requires user interaction. + ## Authentication Helper Wait Behavior The shim scripts (e.g., `dotnet`, `npm`, `nuget`) now include a wait mechanism for the Azure DevOps authentication helper. When invoked, these scripts will: @@ -89,4 +95,4 @@ if the `targetFiles` option is provided, so you may want to include them in the # ~/.bashrc source /custom/path/to/auth-helper.sh -``` \ No newline at end of file +``` diff --git a/src/artifacts-helper/devcontainer-feature.json b/src/artifacts-helper/devcontainer-feature.json index e805008..db0e108 100644 --- a/src/artifacts-helper/devcontainer-feature.json +++ b/src/artifacts-helper/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Azure Artifacts Credential Helper", "id": "artifacts-helper", - "version": "3.0.0", + "version": "3.0.1", "description": "Configures Codespace to authenticate with Azure Artifact feeds", "options": { "nugetURIPrefixes": { diff --git a/src/artifacts-helper/scripts/auth-ado.sh b/src/artifacts-helper/scripts/auth-ado.sh index db54205..9ffc878 100644 --- a/src/artifacts-helper/scripts/auth-ado.sh +++ b/src/artifacts-helper/scripts/auth-ado.sh @@ -1,5 +1,12 @@ #!/bin/bash +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in a GitHub Actions environment +# Skip Azure DevOps authentication and just execute the real command +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + echo "::step::GitHub Actions environment detected, skipping Azure DevOps authentication" + return 0 +fi + echo "::step::Waiting for AzDO Authentication Helper..." # Wait up to 3 minutes for the ado-auth-helper to be installed diff --git a/src/artifacts-helper/scripts/dotnet b/src/artifacts-helper/scripts/dotnet index 7b765e1..854983c 100755 --- a/src/artifacts-helper/scripts/dotnet +++ b/src/artifacts-helper/scripts/dotnet @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + DOTNET_EXE="$(resolve_shim)" + "${DOTNET_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/npm b/src/artifacts-helper/scripts/npm index deef49f..68f914a 100755 --- a/src/artifacts-helper/scripts/npm +++ b/src/artifacts-helper/scripts/npm @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + NPM_EXE="$(resolve_shim)" + "${NPM_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/npx b/src/artifacts-helper/scripts/npx index 1879135..87c98da 100755 --- a/src/artifacts-helper/scripts/npx +++ b/src/artifacts-helper/scripts/npx @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + NPX_EXE="$(resolve_shim)" + "${NPX_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/nuget b/src/artifacts-helper/scripts/nuget index 756c918..58d7c06 100755 --- a/src/artifacts-helper/scripts/nuget +++ b/src/artifacts-helper/scripts/nuget @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + NUGET_EXE="$(resolve_shim)" + "${NUGET_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/pnpm b/src/artifacts-helper/scripts/pnpm index 7cf2e95..fda9f8b 100755 --- a/src/artifacts-helper/scripts/pnpm +++ b/src/artifacts-helper/scripts/pnpm @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + PNPM_EXE="$(resolve_shim)" + "${PNPM_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/pnpx b/src/artifacts-helper/scripts/pnpx index 5f865e0..f778b7a 100755 --- a/src/artifacts-helper/scripts/pnpx +++ b/src/artifacts-helper/scripts/pnpx @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + PNPX_EXE="$(resolve_shim)" + "${PNPX_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/rush b/src/artifacts-helper/scripts/rush index f1c262b..d849432 100755 --- a/src/artifacts-helper/scripts/rush +++ b/src/artifacts-helper/scripts/rush @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + RUSH_EXE="$(resolve_shim)" + "${RUSH_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/rush-pnpm b/src/artifacts-helper/scripts/rush-pnpm index 8370d83..28cefcd 100755 --- a/src/artifacts-helper/scripts/rush-pnpm +++ b/src/artifacts-helper/scripts/rush-pnpm @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + RUSH_PNPM_EXE="$(resolve_shim)" + "${RUSH_PNPM_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh diff --git a/src/artifacts-helper/scripts/yarn b/src/artifacts-helper/scripts/yarn index 5453431..e043030 100755 --- a/src/artifacts-helper/scripts/yarn +++ b/src/artifacts-helper/scripts/yarn @@ -1,4 +1,13 @@ #!/bin/bash + +# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup +if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then + source "$(dirname $0)"/resolve-shim.sh + YARN_EXE="$(resolve_shim)" + "${YARN_EXE}" "$@" + exit $? +fi + source "$(dirname $0)"/auth-ado.sh source "$(dirname $0)"/resolve-shim.sh