Skip to content
Merged
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
9 changes: 2 additions & 7 deletions .github/actions/create-prerelease/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ inputs:
package-path:
description: 'package path to run action e.g. package/common'
required: true
npm-token:
description: 'token to push to npm registry'
required: true


runs:
using: "composite"
steps:
Expand All @@ -19,7 +16,5 @@ runs:
shell: bash

- working-directory: ${{ inputs.package-path }}
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn version prerelease && yarn npm publish --access public --tag dev
env:
NPM_TOKEN: ${{ inputs.npm-token }}
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn version prerelease && yarn npm publish --access public --tag dev
Comment on lines 18 to +19

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

🧩 Analysis chain

🏁 Script executed:

find . -name '.yarnrc.yml' -o -name '.yarnrc' | head -10 | xargs -I {} sh -c 'echo "=== {} ===" && cat "{}"'

Repository: subquery/subql-near

Length of output: 429


🏁 Script executed:

cat -n .github/actions/create-prerelease/action.yml

Repository: subquery/subql-near

Length of output: 983


🏁 Script executed:

find . -path './.git' -prune -o -name '*.yml' -o -name '*.yaml' | grep -E '(\.github/workflows|\.github/actions)' | head -20

Repository: subquery/subql-near

Length of output: 383


🏁 Script executed:

grep -r "create-prerelease" .github/workflows/ 2>/dev/null | head -20

Repository: subquery/subql-near

Length of output: 302


🏁 Script executed:

cat -n .github/workflows/publish.yml

Repository: subquery/subql-near

Length of output: 6082


Configure NPM_TOKEN environment variable in the publish step.

The publish step relies on .yarnrc.yml's npmAuthToken: "${NPM_TOKEN:-}" configuration, but the action does not set the NPM_TOKEN environment variable. While the workflow has id-token: write permission for OIDC, the action itself is not configured to use it. Either pass NPM_TOKEN as a secret from the calling workflow or configure the action to exchange the OIDC token for npm authentication.

🤖 Prompt for AI Agents
In .github/actions/create-prerelease/action.yml around lines 18-19, the publish
run uses .yarnrc.yml npmAuthToken but does not provide NPM_TOKEN; update the
action to set the NPM_TOKEN environment variable before running yarn (either
accept it as an input and map it from the caller's secrets, or implement OIDC
exchange logic to retrieve an npm auth token and export it as NPM_TOKEN), then
run the existing prerelease and publish commands so yarn can read npmAuthToken
from the environment.

shell: bash
5 changes: 0 additions & 5 deletions .github/actions/create-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ inputs:
repo-token:
description: 'token to create github release'
required: true
npm-token:
description: 'token to push to npm registry'
required: true

runs:
using: "composite"
steps:
- working-directory: ${{ inputs.package-path }}
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
env:
NPM_TOKEN: ${{ inputs.npm-token }}
shell: bash

- working-directory: ${{ github.workspace }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ jobs:

steps:
#Check out
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 100
token: ${{ secrets.REPO_TOKEN }}

- name: Install Docker inside the container
run: |
apt-get update
apt-get install -y docker.io
apt-get install -y docker.io

- name: Install PostgreSQL client
run: |
Expand Down Expand Up @@ -186,4 +186,3 @@ jobs:
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/discord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Send release details to Discord
uses: rjstone/discord-webhook-notify@v1
uses: rjstone/discord-webhook-notify@v2
with:
webhookUrl: ${{ secrets.DISCORD_RELEASE_NOTES_WEBHOOK }}
color: '#6499ff'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
#Check out
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 100

- name: Setup Node.js environment
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: lts

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/node-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
outputs:
changes_found: ${{ steps.check_changes.outputs.changes_found }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 2
- name: Check for package changes and commit message
Expand All @@ -39,7 +39,7 @@ jobs:
if: needs.check.outputs.changes_found == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 100
token: ${{ secrets.REPO_TOKEN }}
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
if: needs.check.outputs.changes_found == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 100
token: ${{ secrets.REPO_TOKEN }}
Expand Down Expand Up @@ -148,4 +148,3 @@ jobs:

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

8 changes: 4 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
SUBQL_ACCESS_TOKEN_TEST: ${{ secrets.SUBQL_ACCESS_TOKEN_TEST }}
SUBQL_ORG_TEST: ${{ secrets.SUBQL_ORG_TEST }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5
- name: Setup Node.js environment
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: lts/*
- run: yarn
Expand Down Expand Up @@ -45,10 +45,10 @@ jobs:
DB_HOST: postgres
DB_PORT: 5432
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- name: Use Node LTS
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: lts/*

Expand Down
76 changes: 0 additions & 76 deletions .github/workflows/prerelease.yml

This file was deleted.

173 changes: 173 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: "Publish"
on:
push:
branches:
- main
paths-ignore:
- ".github/workflows/**"

permissions:
id-token: write # Required for OIDC
contents: read

concurrency:
group: publish
cancel-in-progress: false

jobs:

pre-ci:
name: Pre-CI (Extract Commit Message)
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
commit-message: ${{ steps.get_commit_message.outputs.commit-message }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- id: get_commit_message
run: |
COMMIT_MSG_TEMP="${{ github.event.head_commit.message }}"
if [ -n "$COMMIT_MSG_TEMP" ]
then
commit_msg="$COMMIT_MSG_TEMP"
echo "commit-message=${commit_msg}" | head -n 1 >> "$GITHUB_OUTPUT"
else
commit_message=$(git log -1 --pretty=%B | head -n 1)
echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT"
fi
Comment on lines +31 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 script injection vulnerability by passing context through environment variable.

Line 31 directly interpolates ${{ github.event.head_commit.message }} into a bash command, which is vulnerable to script injection if the commit message contains shell metacharacters.

Apply this diff to safely pass the context value through an environment variable:

      - id: get_commit_message
+       env:
+         COMMIT_MSG_TEMP: ${{ github.event.head_commit.message }}
        run: |
-         COMMIT_MSG_TEMP="${{ github.event.head_commit.message }}"
          if [ -n "$COMMIT_MSG_TEMP" ]
          then
            commit_msg="$COMMIT_MSG_TEMP"
            echo "commit-message=${commit_msg}" | head -n 1 >> "$GITHUB_OUTPUT"
          else
            commit_message=$(git log -1 --pretty=%B | head -n 1)
            echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT"
          fi
📝 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
run: |
COMMIT_MSG_TEMP="${{ github.event.head_commit.message }}"
if [ -n "$COMMIT_MSG_TEMP" ]
then
commit_msg="$COMMIT_MSG_TEMP"
echo "commit-message=${commit_msg}" | head -n 1 >> "$GITHUB_OUTPUT"
else
commit_message=$(git log -1 --pretty=%B | head -n 1)
echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT"
fi
- id: get_commit_message
env:
COMMIT_MSG_TEMP: ${{ github.event.head_commit.message }}
run: |
if [ -n "$COMMIT_MSG_TEMP" ]
then
commit_msg="$COMMIT_MSG_TEMP"
echo "commit-message=${commit_msg}" | head -n 1 >> "$GITHUB_OUTPUT"
else
commit_message=$(git log -1 --pretty=%B | head -n 1)
echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT"
fi
🧰 Tools
🪛 actionlint (1.7.9)

31-31: "github.event.head_commit.message" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details

(expression)

🤖 Prompt for AI Agents
.github/workflows/publish.yml around lines 31 to 40: the workflow currently
interpolates ${{ github.event.head_commit.message }} directly into a shell
script which can allow script injection; instead add an environment variable in
the step (e.g., COMMIT_MSG_RAW: "${{ github.event.head_commit.message }}") and
change the script to read from that env var (COMMIT_MSG_TEMP="$COMMIT_MSG_RAW")
so no GitHub expression is expanded inside the shell; ensure you still test for
non-empty safely (use [ -n "$COMMIT_MSG_TEMP" ]) and keep all variable values
quoted when echoing to GITHUB_OUTPUT to preserve content and prevent
word-splitting or unintended execution.


- name: Debug commit message
run: |
echo "Commit message: ${{ steps.get_commit_message.outputs.commit-message }}"

setup:
name: Setup & Detect Changes
needs: pre-ci
runs-on: ubuntu-latest
outputs:
changed-types: ${{ steps.changed-types.outputs.changed }}
changed-common-near: ${{ steps.changed-common-near.outputs.changed }}
changed-node: ${{ steps.changed-node.outputs.changed }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 100 # Needed to detect changes by having commit history

- uses: marceloprado/has-changed-path@v1
id: changed-types
with:
paths: packages/types

- uses: marceloprado/has-changed-path@v1
id: changed-common-near
with:
paths: packages/common-near

- uses: marceloprado/has-changed-path@v1
id: changed-node
with:
paths: packages/node

release:
name: Release Publish
needs: [pre-ci, setup]
if: >
!startsWith(github.event.head_commit.message, '[SKIP CI]')
&& startsWith(github.event.head_commit.message, '[release]')
&& github.repository == 'subquery/subql-near'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup Node.js environment
uses: actions/setup-node@v5
with:
node-version: lts/*

- name: Update npm
run: npm install -g npm@latest

- run: yarn

- name: build
run: yarn build

# Publish to npm and github releases
- name: Publish Types
if: needs.setup.outputs.changed-types == 'true'
uses: ./.github/actions/create-release
with:
package-path: packages/types
repo-token: ${{ secrets.REPO_TOKEN }}

- name: Publish Common Near
if: needs.setup.outputs.changed-common-near == 'true'
uses: ./.github/actions/create-release
with:
package-path: packages/common-near
repo-token: ${{ secrets.REPO_TOKEN }}

- name: Publish Node
if: needs.setup.outputs.changed-node == 'true'
uses: ./.github/actions/create-release
with:
package-path: packages/node
repo-token: ${{ secrets.REPO_TOKEN }}

prerelease:
name: Prerelease Publish
needs: [pre-ci, setup]
if: >
!startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]')
&& !startsWith(needs.pre-ci.outputs.commit-message, '[release]')
&& github.repository == 'subquery/subql-near'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.REPO_TOKEN }} # Needed to push changes back to repo

- name: Setup Node.js environment
uses: actions/setup-node@v5
with:
node-version: lts/*

- name: Update npm
run: npm install -g npm@latest

- run: yarn

- name: build
run: yarn build

# Prerelease publish steps
- name: Bump types & deploy
if: needs.setup.outputs.changed-types == 'true'
uses: ./.github/actions/create-prerelease
with:
package-path: packages/types

- name: Bump common near & deploy
if: needs.setup.outputs.changed-common-near == 'true'
uses: ./.github/actions/create-prerelease
with:
package-path: packages/common-near

- name: Bump node & deploy
if: needs.setup.outputs.changed-node == 'true'
uses: ./.github/actions/create-prerelease
with:
package-path: packages/node


- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: "[SKIP CI] Prerelease"
default_author: github_actions
Loading
Loading