-
Notifications
You must be signed in to change notification settings - Fork 4
Setup workflows #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Setup workflows #43
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: workflow for Master | ||
| on: | ||
| push: | ||
| branches: | ||
| - "master" | ||
| jobs: | ||
| build: | ||
| runs-on: ubicloud-standard-2 | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| packages: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - id: 'auth-spotdraft-qa' | ||
| name: 'Authenticate to Google Cloud' | ||
| uses: 'google-github-actions/auth@v1.1.1' | ||
| with: | ||
| token_format: 'access_token' | ||
| workload_identity_provider: 'projects/400887723303/locations/global/workloadIdentityPools/github-actions-pool/providers/github-provider' | ||
| service_account: 'github-actions@spotdraft-qa.iam.gserviceaccount.com' | ||
|
|
||
| - name: Set up gcloud CLI | ||
| uses: google-github-actions/setup-gcloud@v3 | ||
| with: | ||
| project_id: 'spotdraft-qa' | ||
|
|
||
| - name: Configure NPM to use Artifact Registry | ||
| run: | | ||
| TOKEN=$(gcloud auth print-access-token) | ||
| rm -rf .npmrc | ||
| echo -e "\n//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=\"$TOKEN\"" >> .npmrc | ||
| echo "@spotdraft:registry=https://asia-south1-npm.pkg.dev/spotdraft-qa/npm/" >> .npmrc | ||
|
|
||
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| - name: Publish package | ||
| run: | | ||
| npm publish | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: workflow for PR | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| branches: [master] | ||
| jobs: | ||
| build: | ||
| runs-on: ubicloud-standard-2 | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| packages: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: '24' | ||
|
|
||
| - id: 'auth-spotdraft-qa' | ||
| name: 'Authenticate to Google Cloud' | ||
| uses: 'google-github-actions/auth@v1.1.1' | ||
| with: | ||
| token_format: 'access_token' | ||
| workload_identity_provider: 'projects/400887723303/locations/global/workloadIdentityPools/github-actions-pool/providers/github-provider' | ||
| service_account: 'github-actions@spotdraft-qa.iam.gserviceaccount.com' | ||
|
|
||
| - name: Set up gcloud CLI | ||
| uses: google-github-actions/setup-gcloud@v3 | ||
| with: | ||
| project_id: 'spotdraft-qa' | ||
|
|
||
| - name: Configure NPM to use Artifact Registry | ||
| run: | | ||
| TOKEN=$(gcloud auth print-access-token) | ||
| rm -rf .npmrc | ||
| echo -e "\n//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=\"$TOKEN\"" >> .npmrc | ||
| echo "@spotdraft:registry=https://asia-south1-npm.pkg.dev/spotdraft-qa/npm/" >> .npmrc | ||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix
- TOKEN=$(gcloud auth print-access-token)
- rm -rf .npmrc
- echo -e "\n//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=\"$TOKEN\"" >> .npmrc
- echo "@spotdraft:registry=https://asia-south1-npm.pkg.dev/spotdraft-qa/npm/" >> .npmrc
+ TOKEN="$(gcloud auth print-access-token)"
+ cat <<'EOF' > .npmrc
+//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=${TOKEN}
+@spotdraft:registry=https://asia-south1-npm.pkg.dev/spotdraft-qa/npm/
+EOF
🤖 Prompt for AI Agents |
||
|
|
||
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| - name: Publish package | ||
| run: | | ||
| npm publish --dry-run | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
always-auth=trueso npm actually sends the token.Artifact Registry’s own guidance keeps an
always-auth=trueentry alongside the_authToken. Without it, npm can skip attaching the token on preliminary GET/HEAD requests when publishing, which leads to intermittent 401s duringnpm publish. Please add the flag when building.npmrc.(cloud.google.com)TOKEN=$(gcloud auth print-access-token) rm -rf .npmrc - echo -e "\n//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=\"$TOKEN\"" >> .npmrc + echo -e "\n//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:always-auth=true" >> .npmrc + echo "//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=\"$TOKEN\"" >> .npmrc echo "@spotdraft:registry=https://asia-south1-npm.pkg.dev/spotdraft-qa/npm/" >> .npmrc📝 Committable suggestion
🤖 Prompt for AI Agents