Skip to content

Commit 60470b9

Browse files
authored
update deploy workflow to use oidc and classic hybrid approach (#3686)
1 parent 337eb0f commit 60470b9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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
89
cache: yarn
910
node-version-file: '.nvmrc' # Must be 20+ to support npm 11.5.1+
1011

.github/workflows/deploy.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ 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-
4338
- id: changesets
4439
name: Create release Pull Request or publish to NPM
4540
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
@@ -53,12 +48,18 @@ jobs:
5348

5449
- name: Temporary manual sync 'latest' tag # will be removed after sync
5550
if: github.event_name == 'workflow_dispatch' && github.ref_name == vars.LATEST_STABLE_VERSION
51+
env:
52+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5653
run: |
57-
# Debug info (contents from above)
58-
echo "--- Contents of $HOME/.npmrc ---"
59-
cat "$HOME/.npmrc"
54+
# dist-tag does not support OIDC yet, so fallback to classic token
55+
# overwrite the .npmrc to ensure no OIDC session conflicts
56+
echo "---Overwriting $NPM_CONFIG_USERCONFIG ---"
57+
echo "@shopify:registry=https://registry.npmjs.org/" > "$NPM_CONFIG_USERCONFIG"
58+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> "$NPM_CONFIG_USERCONFIG"
59+
60+
# Debug info
6061
echo "--- npm identity check ---"
61-
npm whoami --registry=https://registry.npmjs.org/ || echo "whoami failed (expected if OIDC not yet triggered)"
62+
npm whoami --registry=https://registry.npmjs.org/
6263
6364
# Run with info logging
6465
npm dist-tag add @shopify/[email protected] latest --loglevel=info
@@ -67,7 +68,13 @@ jobs:
6768
if: steps.changesets.outputs.published == 'true' && github.ref_name == vars.LATEST_STABLE_VERSION
6869
env:
6970
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
71+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7072
run: |
73+
# dist-tag does not support OIDC yet, so fallback to classic token
74+
# overwrite the .npmrc to ensure no OIDC session conflicts
75+
echo "@shopify:registry=https://registry.npmjs.org/" > "$NPM_CONFIG_USERCONFIG"
76+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> "$NPM_CONFIG_USERCONFIG"
77+
7178
for pkg in $(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | @base64'); do
7279
_jq() {
7380
echo ${pkg} | base64 --decode | jq -r ${1}

0 commit comments

Comments
 (0)