fix(ci): auth actions/checkout as bot because it is used for subsequent ops [MEC-2423]#2418
Conversation
…nt ops [MEC-2423]
📝 WalkthroughWalkthroughModifies the GitHub Actions release workflow to pass a Vault-provided GITHUB_TOKEN into checkout, re-enables fetching the automation bot user ID via the GitHub API with validation, configures git user.name/email from that bot ID, and preserves npmrc-based publishing steps. Changes
Sequence Diagram(s)sequenceDiagram
participant GH_Actions as GitHub Actions (workflow)
participant Vault as Vault
participant Checkout as actions/checkout
participant GH_API as GitHub REST API
participant Git as git (local runner)
participant NPM as npm publish
rect rgb(235,245,255)
GH_Actions->>Vault: request GITHUB_TOKEN secret
Vault-->>GH_Actions: GITHUB_TOKEN
end
rect rgb(245,255,235)
GH_Actions->>Checkout: checkout repo (token=GITHUB_TOKEN)
Checkout-->>GH_Actions: workspace ready
end
rect rgb(255,245,235)
GH_Actions->>GH_API: GET /user (using token) -> bot user info
GH_API-->>GH_Actions: bot_user.login / id
GH_Actions->>GH_Actions: validate bot ID
end
GH_Actions->>Git: git config user.name (bot login)
GH_Actions->>Git: git config user.email (bot+no-reply)
GH_Actions->>NPM: enable ~/.npmrc (auth from Vault)
GH_Actions->>NPM: npm publish
NPM-->>GH_Actions: publish result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/release.yaml (1)
46-55: Consider extracting the bot name to an environment variable.The bot name
contentful-automation[bot]is hardcoded in lines 48 and 54. Extracting it to a variable would improve maintainability and reduce the risk of inconsistencies if the bot name needs to change.🔎 Proposed refactor
+ - name: Set bot name + id: bot-config + run: echo "name=contentful-automation[bot]" >> "$GITHUB_OUTPUT" + - name: Get Automation Bot User ID id: get-user-id - run: echo "user-id=$(gh api "/users/contentful-automation[bot]" --jq .id)" >> "$GITHUB_OUTPUT" + run: | + USER_ID=$(gh api "/users/${{ steps.bot-config.outputs.name }}" --jq .id) + if [ -z "$USER_ID" ] || [ "$USER_ID" = "null" ]; then + echo "Error: Failed to retrieve bot user ID" + exit 1 + fi + echo "user-id=$USER_ID" >> "$GITHUB_OUTPUT" env: GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }} - name: Setting up Git User Credentials run: | - git config --global user.name 'contentful-automation[bot]' - git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+contentful-automation[bot]@users.noreply.github.com' + git config --global user.name '${{ steps.bot-config.outputs.name }}' + git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.bot-config.outputs.name }}@users.noreply.github.com'
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/release.yaml
🔇 Additional comments (2)
.github/workflows/release.yaml (2)
39-44: Checkout configuration correctly uses Vault-sourced token for authentication.The
actions/checkout@v6action is available and stable. The checkout step appropriately addresses the authentication issue by using the Vault token, which will be embedded in the git remote URL for subsequent operations. The ref logic correctly handles both workflow_run and workflow_dispatch triggers.
52-55: Verify email consistency between git config and Vault.The constructed email format
{user-id}+contentful-automation[bot]@users.noreply.github.comfollows GitHub's standard bot convention. However, this email (set in git config on line 55) may differ fromGH_USER_EMAILstored in Vault (used by semantic-release on lines 88-91). Since semantic-release uses environment variables that take precedence over git config, commits could be attributed to different email addresses depending on the operation if these values don't match.Confirm that the Vault secret
secret/data/github/automation-app-userstoresGH_USER_EMAILin the same format as the constructed email to ensure consistent commit attribution.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
# [4.49.0](v4.48.2...v4.49.0) (2026-01-02) ### Bug Fixes * add vault step to release github action to retrieve token for version bump in git [EXT-7068] ([#2398](#2398)) ([c913680](c913680)) * bump patch [EXT-7068] ([#2411](#2411)) ([6c4676a](6c4676a)) * **ci:** auth actions/checkout as bot because it is used for subsequent ops [MEC-2423] ([#2418](#2418)) ([d16e9ce](d16e9ce)) * MEC-2423 fix CI actor ([bcc1338](bcc1338)) * MEC-2423 fix npm publishing ([22890e5](22890e5)) * MEC-2423 fix release pipeline ([a5bd8b8](a5bd8b8)) * MEC-2423 fix token passing for release ([#2417](#2417)) ([6e95291](6e95291)) * release job [EXT-7068] ([#2400](#2400)) ([bea6ede](bea6ede)) * remove npm token check since now we use oidc [EXT-7067] ([#2397](#2397)) ([22389d0](22389d0)) * use correct vault-github-actions tag [EXT-7068] ([#2399](#2399)) ([8fb861a](8fb861a)) ### Features * implement trusted publishing for npm releases and remove custom codeql workflow [EXT-7067] ([#2384](#2384)) ([1f6b45b](1f6b45b))
|
🎉 This PR is included in version 4.49.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Purpose of PR
actions/checkoutwithout a token uses the defaultGITHUB_TOKEN(which belongs togithub-actions[bot])This token gets embedded in the
.git/configremote URL.When
@semantic-release/gitruns git push, it uses whatever credentials are in the git configGitHub sees the push as coming from
github-actions[bot], which is not on the bypass listPR Checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.