Skip to content

Commit 1e388cc

Browse files
committed
fix: authenticate token-based dependency pulls via netrc
Embedding the token in git insteadOf URLs makes Xcode's Swift Package Manager hang forever during dependency resolution on macOS runners: SPM asks the keychain for HTTPS credentials (even for public packages) and the headless keychain prompt can never be answered, see actions/runner-images#6233 A ~/.netrc file is the documented way to authenticate both git HTTPS clones (pub get) and xcodebuild/SPM on CI without touching the keychain. The remaining insteadOf rewrites only map ssh-style URLs to HTTPS and contain no credentials.
1 parent 2fc90d7 commit 1e388cc

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

.github/actions/dart-prepare/action.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ runs:
5353
chown -R $(whoami) .
5454
if which flutter > /dev/null; then flutter --disable-analytics; fi
5555
if which dart > /dev/null; then dart --disable-analytics; fi
56-
# --add is required: plain `git config` overwrites the previous value
57-
# for the same url base key, leaving only the last insteadOf rewrite.
58-
# The rewrites are scoped to the famedly org on purpose: rewriting all
59-
# of github.com injects the token into public clones too, which makes
60-
# Xcode's Swift Package Manager hang during dependency resolution.
61-
git config --global --add url."https://x-access-token:${{ inputs.famedly_github_token }}@github.com/famedly/".insteadOf "https://github.com/famedly/"
62-
git config --global --add url."https://x-access-token:${{ inputs.famedly_github_token }}@github.com/famedly/".insteadOf "git@github.com:famedly/"
63-
git config --global --add url."https://x-access-token:${{ inputs.famedly_github_token }}@github.com/famedly/".insteadOf "ssh://git@github.com/famedly/"
56+
# Authenticate via ~/.netrc instead of embedding the token in git URLs:
57+
# git picks it up for HTTPS clones, and Xcode's Swift Package Manager
58+
# uses it instead of the macOS keychain. The keychain has no UI on CI
59+
# runners, which makes SPM dependency resolution hang forever, see
60+
# https://github.com/actions/runner-images/issues/6233
61+
printf 'machine github.com\nlogin x-access-token\npassword %s\n\nmachine api.github.com\nlogin x-access-token\npassword %s\n' \
62+
"${{ inputs.famedly_github_token }}" "${{ inputs.famedly_github_token }}" > ~/.netrc
63+
chmod 600 ~/.netrc
64+
# Rewrite ssh-style dependency URLs to HTTPS so the netrc auth applies.
65+
git config --global --add url."https://github.com/famedly/".insteadOf "git@github.com:famedly/"
66+
git config --global --add url."https://github.com/famedly/".insteadOf "ssh://git@github.com/famedly/"
6467
shell: bash

0 commit comments

Comments
 (0)