Skip to content

Commit 337eb0f

Browse files
authored
Fix NPM OIDC authentication for manual dist-tagging (#3685)
1 parent c563d7e commit 337eb0f

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

.github/workflows/actions/prepare/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ runs:
55
- uses: actions/setup-node@v4
66
name: Setup node.js and yarn
77
with:
8-
registry-url: 'https://registry.npmjs.org' # Required for OIDC
98
cache: yarn
109
node-version-file: '.nvmrc' # Must be 20+ to support npm 11.5.1+
1110

.github/workflows/deploy.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
- name: Update npm to latest
3636
run: npm install -g npm@latest
3737

38+
- name: Configure NPM for OIDC (run steps below)
39+
run: |
40+
echo "//registry.npmjs.org/:_authToken=" > "$HOME/.npmrc"
41+
echo "@shopify:registry=https://registry.npmjs.org/" >> "$HOME/.npmrc"
42+
3843
- id: changesets
3944
name: Create release Pull Request or publish to NPM
4045
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
@@ -49,32 +54,20 @@ jobs:
4954
- name: Temporary manual sync 'latest' tag # will be removed after sync
5055
if: github.event_name == 'workflow_dispatch' && github.ref_name == vars.LATEST_STABLE_VERSION
5156
run: |
52-
# 1. Identify which .npmrc npm is actually using
53-
NPM_RC=${NPM_CONFIG_USERCONFIG:-$HOME/.npmrc}
54-
echo "Writing to: $NPM_RC"
55-
56-
# 2. Configure for OIDC and map scope
57-
# Forces OIDC authentication for raw run commands
58-
echo "//registry.npmjs.org/:_authToken=" > "$NPM_RC"
59-
echo "@shopify:registry=https://registry.npmjs.org/" >> "$NPM_RC"
60-
61-
# 3. Debug info (contents from above)
62-
echo "--- Contents of $NPM_RC ---"
63-
cat "$NPM_RC"
57+
# Debug info (contents from above)
58+
echo "--- Contents of $HOME/.npmrc ---"
59+
cat "$HOME/.npmrc"
6460
echo "--- npm identity check ---"
6561
npm whoami --registry=https://registry.npmjs.org/ || echo "whoami failed (expected if OIDC not yet triggered)"
6662
67-
# 4. Run with info logging
63+
# Run with info logging
6864
npm dist-tag add @shopify/[email protected] latest --loglevel=info
6965
7066
- name: Set 'latest' NPM dist tag
7167
if: steps.changesets.outputs.published == 'true' && github.ref_name == vars.LATEST_STABLE_VERSION
7268
env:
7369
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
7470
run: |
75-
# Forces OIDC authentication for raw run commands
76-
echo "//registry.npmjs.org/:_authToken=" > "$HOME/.npmrc"
77-
7871
for pkg in $(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | @base64'); do
7972
_jq() {
8073
echo ${pkg} | base64 --decode | jq -r ${1}

0 commit comments

Comments
 (0)