Skip to content

Commit 758227b

Browse files
authored
update npm deploy workflow to OIDC. (#3691)
1 parent c0aef02 commit 758227b

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: Prepare repo
22
runs:
33
using: 'composite'
44
steps:
5-
- uses: actions/setup-node@v3
5+
- 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
9-
node-version-file: '.nvmrc'
10+
node-version-file: '.nvmrc' # Must be 20+ to support npm 11.5.1+
1011

1112
- name: Yarn install
1213
run: yarn install --frozen-lockfile

.github/workflows/deploy.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,36 @@ jobs:
1818
changesets:
1919
name: Deploy
2020
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
id-token: write # Required for OIDC
2124
steps:
2225
- uses: actions/checkout@v4
2326
with:
2427
token: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
2528

2629
- uses: ./.github/workflows/actions/prepare
2730

31+
- name: Update npm to latest
32+
run: npm install -g npm@latest
33+
2834
- id: changesets
2935
name: Create release Pull Request or publish to NPM
30-
uses: changesets/action@v1
36+
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
3137
with:
3238
title: Version Packages (${{ github.ref_name }})
3339
publish: yarn run deploy --tag ${{ github.ref_name }}
3440
env:
35-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
NPM_TOKEN: '' # Forces OIDC authentication
3642
GITHUB_TOKEN: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
3743

44+
# Known to fail in OIDC (https://github.com/npm/cli/issues/8547).
45+
# Workaround is to manually ask #help-eng-infrastructure to update `latest` tag.
3846
- name: Set 'latest' NPM dist tag
3947
if: steps.changesets.outputs.published == 'true' && github.ref_name == vars.LATEST_STABLE_VERSION
4048
env:
41-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4249
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
4350
run: |
44-
cat << EOF > "$HOME/.npmrc"
45-
//registry.npmjs.org/:_authToken=$NPM_TOKEN
46-
EOF
4751
for pkg in $(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | @base64'); do
4852
_jq() {
4953
echo ${pkg} | base64 --decode | jq -r ${1}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.10.0
1+
v20.19.6

packages/ui-extensions/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
"access": "public",
7878
"@shopify:registry": "https://registry.npmjs.org/"
7979
},
80+
"repository": {
81+
"type": "git",
82+
"url": "https://github.com/Shopify/ui-extensions.git",
83+
"directory": "packages/ui-extensions"
84+
},
8085
"files": [
8186
"build",
8287
"src",

0 commit comments

Comments
 (0)