Skip to content

feat: notify AM repo when WF is published - #1146

Merged
UladzislauK-Writer merged 1 commit into
devfrom
vlad/AB-505
Nov 6, 2025
Merged

feat: notify AM repo when WF is published#1146
UladzislauK-Writer merged 1 commit into
devfrom
vlad/AB-505

Conversation

@UladzislauK-Writer

@UladzislauK-Writer UladzislauK-Writer commented Oct 27, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Publishing workflow now runs from the dev branch, computes an RC version automatically (queries package index and repo state), selects a final version, and can create/push annotated RC tags for dev releases.
    • Packaging and publish steps apply the computed or provided final version for build and release.
    • Cross-workflow trigger accepts dynamic event types and merged payloads (including commit reference), logs inputs, and dispatches using the combined payload.

@coderabbitai

coderabbitai Bot commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Publish workflow now computes a final RC-style version (Python step querying PyPI and git), selects final_version from inputs/dev-calculated RC/tag/commit_sha, updates Poetry and publishes that version, creates an annotated RC tag on dev, and dispatches a downstream repository event via a reusable workflow converted to workflow_call.

Changes

Cohort / File(s) Summary
Publish workflow (versioning & publish flow)
/.github/workflows/publish.yml
Adds dev trigger and commit_sha input; replaces tag-based version extraction with a Python-driven version-determination flow that queries PyPI, inspects git history, and computes next RC; selects final_version (input → dev RC → tag); updates Poetry version, builds/installs, runs publish steps with final_version; creates & pushes annotated writer-framework-<version> RC tag on dev; installs Python deps and Node.js where needed; adds trigger-agent-manager job to dispatch downstream event on dev.
Reusable trigger workflow
/.github/workflows/trigger-workflow.yml
Converted to workflow_call with inputs event_type (required) and extra_payload (optional); reads commit_sha from runtime, merges it into extra_payload via jq to form client_payload; logs payload and dispatches dynamic event_type with merged client_payload.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as "dev branch / CI"
    participant PublishWF as "publish.yml"
    participant PyPI as "PyPI API"
    participant Git as "git / repo"
    participant TriggerWF as "trigger-workflow.yml"
    participant Downstream as "downstream repo"

    Dev->>+PublishWF: start (commit_sha or tag or manual input)
    PublishWF->>+PyPI: query releases & RCs
    PyPI-->>-PublishWF: releases/versions
    PublishWF->>Git: inspect tags & commits since last stable
    PublishWF-->>PublishWF: compute next RC (Python step)
    alt on dev branch
        PublishWF->>Git: create annotated tag writer-framework-<version>
        Git-->>PublishWF: push tag
    end
    PublishWF->>TriggerWF: workflow_call(event_type, merged_payload with final_version)
    TriggerWF->>Downstream: repository_dispatch with client_payload
    Note right of Downstream: receives final_version in payload
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Inspect Python version-calculation script for correctness (PyPI API usage, semver rules, edge cases).
  • Verify Git/tag creation and push (auth, annotated tag format, idempotency/race conditions).
  • Check outputs wiring (GITHUB_OUTPUT, step outputs) and that final_version propagates to Poetry, build, publish, and downstream dispatch.
  • Validate workflow_call inputs and jq payload merging for robustness.

Possibly related PRs

Suggested reviewers

  • raaymax

Poem

🐇 I hopped to PyPI and counted each tag so fair,
stitched a tiny RC from commits and fresh air,
nudged Poetry, tied a ribbon on dev's new name,
knocked downstream's door with a payload and a flame —
carrots for CI, publish, and fame! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: notify AM repo when WF is published' clearly summarizes the main objective of introducing cross-repository notification functionality when Writer Framework is published.
Linked Issues check ✅ Passed The pull request implements the coding requirements from AB-505: adjusts GitHub Actions workflows to enable AM-WF cross-repository communication for the new release/build flow where publishing occurs in WF and is communicated to AM.
Out of Scope Changes check ✅ Passed All changes in the PR are scoped to implementing the notification mechanism between repositories: publish.yml handles version determination and RC tagging, trigger-workflow.yml enables dynamic event dispatching to AM, both directly supporting AB-505 objectives.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vlad/AB-505

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 and usage tips.

@hackerone-code hackerone-code Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

HackerOne Code Security Review

🟢 Scan Complete: 4 Issue(s)
🟢 Validation Complete: Any Issues detected were validated by one of our engineers. None were determined to require immediate action.

Here's how the code changes were interpreted and info about the tools used for scanning.

📖 Summary of Changes The GitHub Actions workflows were modified to enhance branch-specific publishing and workflow triggering capabilities. The publish workflow now supports dev branch releases with improved version extraction and RC tag creation. The trigger workflow was refactored to become a reusable workflow with dynamic payload merging and added logging for better event tracking and flexibility.
File Summary
.github/workflows/publish.yml The workflow file was updated to support publishing from the 'dev' branch, with changes to version extraction logic, added RC version determination, and a new step to create and push RC tags when publishing from the development branch.
.github/workflows/trigger-workflow.yml The workflow changed from a push-triggered action to a reusable workflow with optional inputs. It now dynamically merges commit SHA and extra payload using jq, and adds logging for the triggered event type and payload.
ℹ️ Issues Detected

NOTE: These may not require action!

Below are unvalidated results from the Analysis Tools that ran during the latest scan for transparency. We investigate each of these for accuracy and relevance before surfacing them as a potential problem.

How will I know if something is a problem?
When validation completes, any concerns that warrant attention prior to merge will be posted as inline comments. These will show up in 2 ways:

  • Expert review (most cases): Issues will be posted by experts who manually reviewed and validated them. These are real HackerOne engineers (not bots) reviewing through an integrated IDE-like tool. You can communicate with them like any other reviewer. They'll stay assigned and get notified with commit & comment updates.
  • Automatically: In cases where our validation checks have highest confidence the problem is legitimate and urgent. These will include a description of contextual reasoning why & actionable next steps.
File & Line Issue
.github/workflows/publish.yml Line 58 The script uses unsanitized git log output in a regex pattern, which could potentially lead to unexpected behavior if commit messages contain special regex characters.
.github/workflows/publish.yml Line 45 The script makes an HTTP request to PyPI without verifying SSL certificates. This could allow for man-in-the-middle attacks where an attacker could intercept sensitive information or inject malicious responses.
.github/workflows/trigger-workflow.yml Line 24 Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
.github/workflows/publish.yml Line 77 Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
🧰 Analysis tools

⏱️ Latest scan covered changes up to commit ab05041 (latest)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 1a629d9 and 715e4c1.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (2 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.10)
  • GitHub Check: tests (firefox)
  • GitHub Check: tests (webkit)
  • GitHub Check: tests (chromium)
🔇 Additional comments (3)
.github/workflows/publish.yml (1)

73-76: Verify reusable workflow invocation and input mapping.

The step invokes the reusable workflow with event_type: framework_published. Ensure this aligns with the input definition in .github/workflows/trigger-workflow.yml (which expects event_type as a required string input). Verify that both the push-to-dev trigger and this workflow_call invocation correctly pass/default the event_type variable downstream.

.github/workflows/trigger-workflow.yml (2)

7-12: LGTM on workflow_call trigger definition.

The reusable workflow trigger is properly defined with a required event_type input, enabling external workflows to invoke this workflow with a custom event type. This supports the publish workflow's new framework_published event.


26-26: Let me check the publish.yml file to understand the complete context of how trigger-workflow.yml is called:

Based on my verification of GitHub Actions expression language behavior and the workflow configuration:

Variable expansion works correctly in both trigger scenarios.

When the workflow is triggered by push, the whole inputs context is unavailable, which evaluates to an empty string. Empty string is a falsy value in GitHub Actions conditionals, so the || operator correctly triggers the fallback. For string inputs you can use the || expression operator to set the default value, and this pattern ${{ github.event.inputs.name || 'Octocat' }} solves the issue without hassle.

Your implementation correctly defaults to 'framework_updated' when triggered via push to dev (where github.event.inputs is unavailable) and uses the passed value when invoked via workflow_call from publish.yml.

Comment thread .github/workflows/publish.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 715e4c1 and 4c1e494.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (2 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/trigger-workflow.yml
🧰 Additional context used
🪛 actionlint (1.7.8)
.github/workflows/publish.yml

33-33: property "pr" is not defined in object type {}

(expression)


84-84: property "extract_version" is not defined in object type {bump_rc: {conclusion: string; outcome: string; outputs: {string => string}}}

(expression)


90-90: property "extract_version" is not defined in object type {bump_rc: {conclusion: string; outcome: string; outputs: {string => string}}}

(expression)


93-93: property "extract_version" is not defined in object type {bump_rc: {conclusion: string; outcome: string; outputs: {string => string}}}

(expression)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: tests (firefox)
  • GitHub Check: build (3.9)
  • GitHub Check: tests (webkit)
  • GitHub Check: tests (chromium)
🔇 Additional comments (1)
.github/workflows/publish.yml (1)

97-100: The syntax in the review comment is actually valid; the real issue is the missing workflow file.

GitHub Actions documentation confirms that uses: ./.github/workflows/filename.yml is the correct syntax for calling a reusable workflow in the same repository. The code at lines 97-100 follows this exact pattern correctly.

However, the verification revealed that trigger-workflow.yml does not exist in the repository—so while the syntax is valid, the referenced file is missing. The review comment's premise is flawed: it incorrectly identifies valid syntax as invalid and suggests unnecessary workarounds (like adding @${{ github.ref }}, using CLI, or treating it as an action directory).

Actual issue: The file .github/workflows/trigger-workflow.yml must be created for this step to function, or the reference must point to an existing workflow file.

Likely an incorrect or invalid review comment.

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
@UladzislauK-Writer
UladzislauK-Writer force-pushed the vlad/AB-505 branch 2 times, most recently from 4e4e32e to 794111b Compare October 28, 2025 11:58
Comment thread .github/workflows/trigger-workflow.yml Fixed
Comment thread .github/workflows/trigger-workflow.yml Fixed
Comment thread .github/workflows/trigger-workflow.yml Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 4c1e494 and 794111b.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (2 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
.github/workflows/trigger-workflow.yml

[warning] 27-27: Code injection
Potential code injection in ${{ github.event.inputs.event_type || 'framework_updated' }}, which may be controlled by an external user.


[warning] 28-28: Code injection
Potential code injection in ${{ github.sha }}, which may be controlled by an external user.


[warning] 29-29: Code injection
Potential code injection in ${{ github.event.inputs.extra_payload || '{}' }}, which may be controlled by an external user.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.10)
  • GitHub Check: tests (firefox)
  • GitHub Check: tests (chromium)
  • GitHub Check: tests (webkit)
🔇 Additional comments (5)
.github/workflows/trigger-workflow.yml (2)

4-13: Workflow structure converted correctly to reusable workflow_call.

The migration from push-based trigger to workflow_call with event_type and extra_payload inputs is properly structured and supports dynamic triggering from publish.yml.


27-29: CodeQL flags code injection; assess context for actual risk.

CodeQL warns that event_type, commit_sha, and extra_payload are user-controlled inputs. In the current flow (called from publish.yml with hardcoded values), this is not exploitable. However, since this is now a reusable workflow_call, future callers could provide malicious inputs.

Mitigation: Consider adding input validation, especially for event_type. For example, restrict it to a known pattern like [a-z_]+ using a regex check before use.

Current usage: The payload construction via jq -n --argjson and JSON quoting should safely handle the inputs; this is a defensive-coding enhancement rather than a blocking fix.

Also applies to: 34-45

.github/workflows/publish.yml (3)

4-8: Trigger configuration and inputs updated correctly.

Push trigger now covers the dev branch and writer-framework-* tags. Inputs properly renamed to commit_sha and optional version override for explicit control. Aligns with the RC/versioning flow.

Also applies to: 11-16


102-119: Version determination logic is sound.

The fallback chain correctly prioritizes explicit version input → dev RC version → tag-based version. Output naming and step ID are consistent with consumer steps (122, 128, 131).


135-146: RC tag creation and push logic is correct.

Creates and pushes annotated tag only on dev branch, with proper git config and GitHub token. Version source from RC calculation step is correct.

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 794111b and a737ca7.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (1 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/trigger-workflow.yml
🧰 Additional context used
🪛 actionlint (1.7.8)
.github/workflows/publish.yml

154-154: reusable workflow call "./.github/workflows/trigger-workflow.yml@dev" at "uses" is not following the format "owner/repo/path/to/workflow.yml@ref" nor "./path/to/workflow.yml". see https://docs.github.com/en/actions/learn-github-actions/reusing-workflows for more details

(workflow-call)


157-157: context "steps" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)


157-157: property "set_version" is not defined in object type {}

(expression)

🪛 GitHub Check: CodeQL
.github/workflows/publish.yml

[warning] 152-161: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.11)
  • GitHub Check: tests (chromium)
  • GitHub Check: tests (firefox)
  • GitHub Check: tests (webkit)

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml Outdated
Comment on lines +152 to +161
needs: build
if: github.ref_name == 'dev'
uses: ./.github/workflows/trigger-workflow.yml
with:
event_type: framework_updated
extra_payload: |
{
"tag": "writer-framework-${{ needs.build.outputs.version }}",
"version": "${{ needs.build.outputs.version }}",
}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 9 months ago

To fix this issue, you should add a permissions: section in the workflow. The safest general approach is to set it at the workflow root (just below the name: and on: blocks), which will apply to all jobs unless overridden. This prevents all jobs from having unnecessary broad permissions. For jobs or steps that require elevated permissions (e.g., git push to create tags, or actions needing repository/contents write), set only the specific write permissions actually required for those steps or jobs. Based on the shown workflow, writing tags (git push) and using the default GITHUB_TOKEN for git operations means the job must have at least contents: write. For publishing to PyPI (using PYPI_TOKEN) and triggering downstream workflows, only read permission is required for contents.

Step by step:

  • Add a root-level permissions: block with minimal required permissions, likely:
    • contents: write for jobs that push tags (build)
    • If some jobs do not need write, limit them further (e.g., root could be contents: read, but for simplicity and to avoid step-level overrides, root can be contents: write).
  • Optionally, restrict further with job-level overwrites if needed.
  • The trigger-agent-manager job uses secrets (but only triggers another workflow), so contents: read suffices.

Best file location: At the root of .github/workflows/publish.yml, below name: publish and above or below on:.

Suggested changeset 1
.github/workflows/publish.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -1,5 +1,8 @@
 name: publish
 
+permissions:
+  contents: write
+
 on:
     push:
         branches:
EOF
@@ -1,5 +1,8 @@
name: publish

permissions:
contents: write

on:
push:
branches:
Copilot is powered by AI and may make mistakes. Always verify output.
@UladzislauK-Writer UladzislauK-Writer committed this autofix suggestion 9 months ago.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
.github/workflows/publish.yml (1)

114-124: Major: Missing explicit permissions block for GITHUB_TOKEN.

The trigger-agent-manager job does not declare an explicit permissions block. While this job uses a reusable workflow, it should still declare what permissions are required. This is a security best practice flagged by static analysis.

    trigger-agent-manager:
        needs: build
        if: github.ref_name == 'dev'
+       permissions:
+           contents: read
        uses: ./.github/workflows/trigger-workflow.yml
        with:
            event_type: framework_updated
🧹 Nitpick comments (1)
.github/workflows/publish.yml (1)

42-66: Recommended: Add error handling to the Python version-bump script.

The inline Python script (lines 42-66) queries PyPI and inspects git history but lacks error handling for network failures, malformed API responses, or missing git data. Consider wrapping the main logic in a try-except block and providing meaningful error messages.

try:
    data = requests.get(f"https://pypi.org/pypi/writer/json", timeout=10).json()
    # ... rest of logic ...
except requests.RequestException as e:
    print(f"Error fetching PyPI data: {e}", file=sys.stderr)
    sys.exit(1)
except (KeyError, ValueError) as e:
    print(f"Error parsing PyPI response: {e}", file=sys.stderr)
    sys.exit(1)
📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 6604ac2 and 66e971b.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (1 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/trigger-workflow.yml
🧰 Additional context used
🪛 GitHub Check: CodeQL
.github/workflows/publish.yml

[warning] 115-124: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: tests (webkit)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: tests (firefox)
  • GitHub Check: tests (chromium)
🔇 Additional comments (2)
.github/workflows/publish.yml (2)

75-92: Verify version determination logic handles all expected paths correctly.

The Determine final version step implements three paths: manual input, dev branch RC, and tag-based. Ensure that:

  • The dev branch always produces a valid RC version from steps.bump_version.outputs.version
  • Tag-based versions correctly strip the writer-framework- prefix
  • The fallback error message is informative when debugging

This logic appears sound, but it would benefit from additional logging or validation to catch configuration issues early.


60-66: Critical: Unguarded list access causes IndexError when no RC versions exist.

Line 62 accesses rc_versions[-1] without checking if the list is empty. When publishing the first RC version (no prior RC releases on PyPI), this will raise an IndexError.

                rc_versions = [v for v in data["releases"] if v.startswith(rc_prefix) and "rc" in v]
-               rc_num = int(re.search(r"rc(\d+)", rc_versions[-1]).group(1)) + 1 if rc_versions else 1
+               rc_num = 1
+               if rc_versions:
+                   rc_num = int(re.search(r"rc(\d+)", rc_versions[-1]).group(1)) + 1
                final = f"{rc_prefix}rc{rc_num}"

Likely an incorrect or invalid review comment.

Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/trigger-workflow.yml
Comment thread .github/workflows/trigger-workflow.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/publish.yml (1)

114-124: Missing explicit permissions block for downstream workflow dispatch.

The trigger-agent-manager job lacks a permissions block. GitHub Actions recommends explicitly declaring GITHUB_TOKEN permissions to minimize the blast radius of potential compromises. Since this job dispatches to an external repository, it should declare the minimal required permissions.

Add a permissions block to this job:

  trigger-agent-manager:
      needs: build
      if: github.ref_name == 'dev'
+     permissions:
+       contents: read
      uses: ./.github/workflows/trigger-workflow.yml
📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between e198185 and a9247bf.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (1 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-23T12:26:44.366Z
Learnt from: UladzislauK-Writer
Repo: writer/writer-framework PR: 1139
File: .github/workflows/publish.yml:6-6
Timestamp: 2025-09-23T12:26:44.366Z
Learning: GitHub Actions tag filters support glob patterns with regex-like characters including [0-9]+, (rc[0-9]+)?, *, **, +, ?, ! and others as documented in the official GitHub Actions workflow syntax documentation. These patterns work correctly for triggering workflows based on tag names.

Applied to files:

  • .github/workflows/publish.yml
🪛 actionlint (1.7.8)
.github/workflows/trigger-workflow.yml

9-9: invalid value "choice" for input type of workflow_call event. it must be one of "boolean", "number", or "string"

(syntax-check)


10-10: unexpected key "options" for "inputs at workflow_call event" section. expected one of "default", "description", "required", "type"

(syntax-check)

🪛 GitHub Check: CodeQL
.github/workflows/publish.yml

[warning] 115-124: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: tests (webkit)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.11)
  • GitHub Check: tests (chromium)
  • GitHub Check: tests (firefox)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
🔇 Additional comments (6)
.github/workflows/publish.yml (4)

103-112: Verify git push authorization and tag fetch behavior.

The RC tag creation and push logic looks correct, but ensure the following:

  1. The actions/checkout@v4 action (line 26) should fetch all tags by default. Verify this doesn't cause issues if tags haven't been fetched from origin.
  2. The GITHUB_TOKEN must have the contents: write permission to push tags. Ensure the job-level permissions (which are missing per the prior comment) include contents: write.

Without explicit permissions, the job inherits the default token permissions, which may or may not include tag-write access depending on repository settings.


53-56: Missing error handling for git log when tag doesn't exist.

The git log command on line 53-56 assumes the tag writer-framework-{latest} exists locally. If the repository was freshly cloned with limited tag fetching or if tags haven't been synchronized, this command will fail with a fatal error.

The AI summary mentions this was addressed in past commits, but I don't see a try/except wrapper in the current code. Verify that:

  1. actions/checkout@v4 on line 26 fetches all tags (default behavior should include fetch-tags: true)
  2. If the tag fetch is limited, add error handling:
try:
    log = subprocess.check_output(
        ["git", "log", f"writer-framework-{latest}..HEAD", "--pretty=%s"],
        text=True
    )
except subprocess.CalledProcessError:
    log = ""  # Fallback: assume all commits are new

75-92: Final version determination logic is well-structured.

The multi-priority version resolution strategy (explicit input → dev-branch-RC → tag-based → error) is clear and follows expected behavior. The step correctly references the earlier bump_version step output and handles all trigger scenarios.


94-101: Poetry version update and publish steps correctly reference version output.

The steps properly reference steps.set_version.outputs.version and pass required environment variables. The secret reference for PYPI_TOKEN follows standard patterns.

.github/workflows/trigger-workflow.yml (2)

25-46: Payload construction and API call look well-structured.

The use of jq to merge commit_sha into extra_payload is robust and ensures valid JSON output. The curl command properly passes the merged payload to the GitHub repository dispatch API. The PAT token reference for authorization is appropriate.

One minor note: ensure that the AGENT_MANAGER_PAT secret has the necessary repo or public_repo scopes to trigger repository dispatch events in the external repository.


17-18: Permissions declaration is appropriately minimal.

The contents: read permission is sufficient since the workflow only reads repository context and doesn't modify any repository content. Authorization for the external repository dispatch is properly delegated to the AGENT_MANAGER_PAT secret.

Comment thread .github/workflows/trigger-workflow.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
.github/workflows/publish.yml (2)

103-112: RC tagging requires write permission to the repository.

The step creates an annotated tag and pushes it to origin, which requires the GITHUB_TOKEN to have contents: write permission. However, neither the workflow root nor the build job declares explicit permissions. While the default token may have these permissions depending on repository settings, it's a best practice to declare them explicitly.

Add a permissions block at the workflow root or job level:

+ permissions:
+   contents: write
+
  jobs:
    build:
      runs-on: ubuntu-latest

Would you like me to add the explicit permissions block to the workflow?


53-56: Error handling for missing git tag is necessary — add try-except block or explicitly fetch tags.

The review comment is correct. actions/checkout@v4 does not fetch tags by default — fetch-tags defaults to false. The workflow at line 26 uses actions/checkout@v4 without the fetch-tags parameter, so the tag writer-framework-{latest} will not be available locally. The subprocess.check_output() call at lines 53-56 will fail with CalledProcessError if the tag is missing, causing the workflow to crash.

Add error handling:

- log = subprocess.check_output(
-     ["git", "log", f"writer-framework-{latest}..HEAD", "--pretty=%s"],
-     text=True
- )
+ try:
+     log = subprocess.check_output(
+         ["git", "log", f"writer-framework-{latest}..HEAD", "--pretty=%s"],
+         text=True,
+         stderr=subprocess.PIPE
+     )
+ except subprocess.CalledProcessError as e:
+     print(f"Warning: git log failed, tag may not exist: {e.stderr}")
+     log = ""

Alternatively, add fetch-tags: true to the checkout action at line 26.

🧹 Nitpick comments (1)
.github/workflows/publish.yml (1)

114-124: trigger-agent-manager job needs explicit permissions to dispatch workflows.

The job calls the reusable workflow to dispatch an event to the agent manager repository. Since this crosses repository boundaries (dispatching to WriterInternal/be.agent-manager), explicit permissions should be declared. The trigger-workflow.yml reusable workflow uses a personal access token (AGENT_MANAGER_PAT), so it does not depend on the default GITHUB_TOKEN permissions here, but it is still a best practice to declare what the job intends to do.

Add permissions to the job:

  trigger-agent-manager:
      needs: build
      if: github.ref_name == 'dev'
+     permissions:
+       contents: read
      uses: ./.github/workflows/trigger-workflow.yml
      with:
          event_type: framework_updated
          extra_payload: |
            {
              "tag": "writer-framework-${{ needs.build.outputs.version }}",
              "version": "${{ needs.build.outputs.version }}"
            }
📜 Review details

Configuration used: CodeRabbit UI

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.

📥 Commits

Reviewing files that changed from the base of the PR and between a9247bf and ab05041.

📒 Files selected for processing (2)
  • .github/workflows/publish.yml (1 hunks)
  • .github/workflows/trigger-workflow.yml (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-23T12:26:44.366Z
Learnt from: UladzislauK-Writer
Repo: writer/writer-framework PR: 1139
File: .github/workflows/publish.yml:6-6
Timestamp: 2025-09-23T12:26:44.366Z
Learning: GitHub Actions tag filters support glob patterns with regex-like characters including [0-9]+, (rc[0-9]+)?, *, **, +, ?, ! and others as documented in the official GitHub Actions workflow syntax documentation. These patterns work correctly for triggering workflows based on tag names.

Applied to files:

  • .github/workflows/publish.yml
🪛 GitHub Check: CodeQL
.github/workflows/publish.yml

[warning] 115-124: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.9)
  • GitHub Check: tests (firefox)
  • GitHub Check: tests (chromium)
  • GitHub Check: tests (webkit)
  • GitHub Check: build (3.10)
🔇 Additional comments (2)
.github/workflows/trigger-workflow.yml (2)

4-13: workflow_call syntax is correct.

The input types are now properly defined as string (not the invalid choice type from previous iterations). The descriptions are clear and the inputs align with what trigger-workflow.yml expects.


27-45: JSON merging and dispatch payload look sound.

Using jq to safely merge commit_sha into the extra payload JSON is a solid approach. The event_type is properly quoted in the curl command, and the merged payload is injected as a JSON object. However, ensure that upstream callers validate the extra_payload input—if malformed JSON is passed, jq will fail silently and the workflow will error. Consider adding a validation step or error handling if this becomes an issue.

Comment thread .github/workflows/publish.yml
@UladzislauK-Writer
UladzislauK-Writer merged commit 22d14c8 into dev Nov 6, 2025
20 checks passed
@UladzislauK-Writer
UladzislauK-Writer deleted the vlad/AB-505 branch November 6, 2025 15:38
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.

3 participants