Skip to content

Commit 655b5fc

Browse files
authored
Merge pull request #88 from microsoft/copilot/fix-artifacts-helper-shims
Skip Azure DevOps auth in shims when ACTIONS_ID_TOKEN_REQUEST_URL is set
2 parents 6e3f193 + 68b07fc commit 655b5fc

File tree

12 files changed

+96
-2
lines changed

12 files changed

+96
-2
lines changed

src/artifacts-helper/NOTES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ pip install <package_name> --index-url https://pkgs.dev.azure.com/<org_name>/_pa
3838
When the feed URL is an Azure Artifacts feed pip will use the keyring helper to provide the credentials needed
3939
to download the package.
4040

41+
## GitHub Actions / Codespaces Prebuild Support
42+
43+
**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.
44+
45+
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.
46+
4147
## Authentication Helper Wait Behavior
4248

4349
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
8995
# ~/.bashrc
9096

9197
source /custom/path/to/auth-helper.sh
92-
```
98+
```

src/artifacts-helper/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Azure Artifacts Credential Helper",
33
"id": "artifacts-helper",
4-
"version": "3.0.0",
4+
"version": "3.0.1",
55
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
66
"options": {
77
"nugetURIPrefixes": {

src/artifacts-helper/scripts/auth-ado.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/bin/bash
22

3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in a GitHub Actions environment
4+
# Skip Azure DevOps authentication and just execute the real command
5+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
6+
echo "::step::GitHub Actions environment detected, skipping Azure DevOps authentication"
7+
return 0
8+
fi
9+
310
echo "::step::Waiting for AzDO Authentication Helper..."
411

512
# Wait up to 3 minutes for the ado-auth-helper to be installed

src/artifacts-helper/scripts/dotnet

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
DOTNET_EXE="$(resolve_shim)"
7+
"${DOTNET_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

src/artifacts-helper/scripts/npm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
NPM_EXE="$(resolve_shim)"
7+
"${NPM_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

src/artifacts-helper/scripts/npx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
NPX_EXE="$(resolve_shim)"
7+
"${NPX_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

src/artifacts-helper/scripts/nuget

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
NUGET_EXE="$(resolve_shim)"
7+
"${NUGET_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

src/artifacts-helper/scripts/pnpm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
PNPM_EXE="$(resolve_shim)"
7+
"${PNPM_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

src/artifacts-helper/scripts/pnpx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
PNPX_EXE="$(resolve_shim)"
7+
"${PNPX_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

src/artifacts-helper/scripts/rush

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
3+
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in GitHub Actions - skip Azure DevOps setup
4+
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
5+
source "$(dirname $0)"/resolve-shim.sh
6+
RUSH_EXE="$(resolve_shim)"
7+
"${RUSH_EXE}" "$@"
8+
exit $?
9+
fi
10+
211
source "$(dirname $0)"/auth-ado.sh
312
source "$(dirname $0)"/resolve-shim.sh
413

0 commit comments

Comments
 (0)