Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/master.yaml
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
Comment on lines +35 to +39
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo -e "..._authToken="$TOKEN"" expands the freshly minted GCP access token inside the logged shell command, so the raw token is emitted in every workflow log (same lines exist in pr.yaml); can we mask the token (e.g. echo "::add-mask::$TOKEN") or otherwise avoid printing the value when writing .npmrc?

Suggested change
- 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
- name: Configure NPM to use Artifact Registry
run: |
TOKEN=$(gcloud auth print-access-token)
echo "::add-mask::$TOKEN" && rm -rf .npmrc && echo -e "\n//asia-south1-npm.pkg.dev/spotdraft-qa/npm/:_authToken=\"$TOKEN\"" >> .npmrc

Finding type: Basic Security Patterns

echo "@spotdraft:registry=https://asia-south1-npm.pkg.dev/spotdraft-qa/npm/" >> .npmrc
Comment on lines +35 to +40
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add always-auth=true so npm actually sends the token.

Artifact Registry’s own guidance keeps an always-auth=true entry alongside the _authToken. Without it, npm can skip attaching the token on preliminary GET/HEAD requests when publishing, which leads to intermittent 401s during npm 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- 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: 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/: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
🤖 Prompt for AI Agents
In .github/workflows/master.yaml around lines 35 to 40, the workflow writes an
.npmrc with the _authToken and registry but omits the always-auth flag; update
the script that builds .npmrc to append an always-auth=true entry (for the
registry in question) immediately after writing the _authToken so npm will
always send the token and avoid intermittent 401s during publish.


- name: Install dependencies
run: npm install

- name: Publish package
run: |
npm publish
47 changes: 47 additions & 0 deletions .github/workflows/pr.yaml
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'
Comment on lines +17 to +20
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR workflow now sets node-version: '24' while the master publish workflow still uses Node 20, so the dry-run on PRs no longer validates the actual publish environment and Node 20–specific build/publish regressions can slip through; can we pin the same Node version in both workflows?

Suggested change
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '24'
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'

Finding type: Logical Bugs


- 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix _authToken quoting to avoid authentication failure.

.npmrc keeps the double quotes you echo around ${TOKEN}, so npm sends Bearer "token" and Artifact Registry rejects the publish (dry-run or real). Drop the quotes and write the file in one shot.

-          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

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In .github/workflows/pr.yaml around lines 37 to 40, the current echo adds
literal double quotes around the auth token and appends each line separately;
change it to write the .npmrc in a single write operation and remove the
surrounding quotes so the _authToken is written as ...:_authToken=<TOKEN> (no
quotes). Ensure the command writes both registry lines to .npmrc atomically
(overwrite, not append) and that the token is inserted raw so npm sends Bearer
<token> without embedded quotes.


- name: Install dependencies
run: npm install

- name: Publish package
run: |
npm publish --dry-run
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "liquidjs",
"name": "@spotdraft/liquidjs",
"version": "3.1.0",
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",
Comment on lines 1 to 4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming the package to @spotdraft/liquidjs while the publish workflow only authenticates/publishes to the scoped registry means npm install liquidjs stops receiving updates yet README/install docs still point to the unscoped name; can we keep publishing an alias named liquidjs or explicitly document the new scoped package before the contract is broken?

Suggested change
{
"name": "liquidjs",
"name": "@spotdraft/liquidjs",
"version": "3.1.0",
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",
{
"name": "liquidjs",
"version": "3.1.0",
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",

Finding type: Breaking Changes

"main": "index.js",
Expand Down
Loading