Skip to content

ci: read the commit message from env in the publish workflow - #3041

Open
kobihikri wants to merge 1 commit into
subquery:mainfrom
kobihikri:ci/commit-message-via-env
Open

ci: read the commit message from env in the publish workflow#3041
kobihikri wants to merge 1 commit into
subquery:mainfrom
kobihikri:ci/commit-message-via-env

Conversation

@kobihikri

@kobihikri kobihikri commented Jul 28, 2026

Copy link
Copy Markdown

Hi, and thanks for SubQuery.

In .github/workflows/publish.yml, the get_commit_message step reads the commit message by interpolation, in two places:

run: |
  if [ -n "${{ github.event.head_commit.message }}" ]
  then
    echo "commit-message=${{ github.event.head_commit.message }}" | head -n 1 >> "$GITHUB_OUTPUT"

Actions expands ${{ ... }} into the script text before bash runs, so the message becomes part of the command rather than a value. A commit message is free text that arrives with whatever a contributor wrote in the PR that got merged, and $(...) and backticks still run inside double quotes.

This is the publish workflow — it has id-token: write for OIDC — which is why I thought it worth raising rather than leaving alone. It is on: push to main, so a message only reaches here after someone merged it; this is not open to a drive-by, and I would rather say that than imply otherwise.

The change reads the message from the environment:

env:
  COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
  if [ -n "$COMMIT_MESSAGE" ]
  then
    printf 'commit-message=%s\n' "$COMMIT_MESSAGE" | head -n 1 >> "$GITHUB_OUTPUT"

I switched echo for printf in that line so a message starting with something like -n is not read as a flag. The head -n 1 truncation, the git log fallback branch and the step output name are all unchanged, so commit-message comes out the same.

Disclosure: I used AI assistance to help spot this and prepare the change, and I read the workflow and its trigger myself.

Summary by CodeRabbit

  • Chores
    • Improved commit-message handling in the continuous integration workflow.
    • Added a fallback to retrieve the latest commit message when event metadata is unavailable.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ebcec6cc-163f-460c-8008-97076048fd2a

📥 Commits

Reviewing files that changed from the base of the PR and between 51e2a2c and e4be4c1.

📒 Files selected for processing (1)
  • .github/workflows/publish.yml

📝 Walkthrough

Walkthrough

The publish workflow’s pre-ci job now passes the head commit message through COMMIT_MESSAGE, conditionally writes its first line as output, and retains the git log fallback when no event message is available.

Changes

Publish workflow

Layer / File(s) Summary
Commit message extraction
.github/workflows/publish.yml
The script uses COMMIT_MESSAGE for the emptiness check, outputs its first line when present, and falls back to git log -1 --pretty=%B otherwise.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the workflow change to read the commit message from an environment variable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant