Skip to content

[ci] Added automated backport workflow#270

Open
atif09 wants to merge 5 commits intoopenwisp:masterfrom
atif09:feature/backport-workflow
Open

[ci] Added automated backport workflow#270
atif09 wants to merge 5 commits intoopenwisp:masterfrom
atif09:feature/backport-workflow

Conversation

@atif09
Copy link
Contributor

@atif09 atif09 commented Feb 22, 2026

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow file is added to automate backporting fixes to stable branches. The workflow is triggered on push events to master/main and on issue comments starting with /backport in merged pull requests. Two jobs delegate to a reusable workflow from openwisp-utils: one for push-triggered backports using commit SHA, and another for comment-triggered backports using PR number and comment body. Both jobs pass necessary bot secrets for authentication.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[ci] Added automated backport workflow' accurately describes the main change - adding a new GitHub Actions workflow for automated backporting to stable branches.
Description check ✅ Passed The description links to the related issue, which establishes context for the change even though it lacks detailed explanation of the implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@atif09 atif09 force-pushed the feature/backport-workflow branch from 5f248fa to f243571 Compare February 24, 2026 18:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/backport.yml:
- Line 44: Remove the extra trailing blank line in the backport.yml workflow
file to satisfy YAML lint’s empty-lines rule; open backport.yml and delete the
blank line at the end of the file so the file ends immediately after the last
non-empty line.
- Line 22: Replace the mutable reference
"openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master" with an
immutable full commit SHA (e.g.
"openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@<full-commit-sha>")
in both occurrences referenced in the workflow; locate the current upstream
commit you want to pin to, copy its full 40-character SHA and substitute it for
"@master" so the reusable workflow is pinned to that exact commit.
- Around line 30-36: The condition uses
github.event.issue.pull_request.merged_at which is not present on issue_comment
events; remove that check from the if and instead let the workflow trigger on
the comment and then fetch the full PR to verify merge status (use the PR number
from github.event.issue.pull_request and call the REST/GraphQL API in a step)
before proceeding with the backport logic; keep the existing checks for event
name, author association (contains(...)) and
startsWith(github.event.comment.body, '/backport'), and add a step that calls
the GitHub API to confirm the PR's merged state (e.g., check the PR resource's
merged boolean) before running backport steps.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a648839 and 0bbe58f.

📒 Files selected for processing (1)
  • .github/workflows/backport.yml
📜 Review details
🧰 Additional context used
🪛 YAMLlint (1.38.0)
.github/workflows/backport.yml

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 44-44: too many blank lines (1 > 0)

(empty-lines)

🔇 Additional comments (1)
.github/workflows/backport.yml (1)

11-18: Concurrency and baseline permissions are well-scoped for this workflow’s intent.

cancel-in-progress: false and explicit contents/pull-requests permissions are appropriate here.

jobs:
backport-on-push:
if: github.event_name == 'push'
uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

GitHub official recommendations pinning third-party actions reusable workflows security best practices

💡 Result:

GitHub official security recommendations (third‑party actions + reusable workflows)

  • Pin to a full-length commit SHA (immutable) for all third-party actions; this is GitHub’s primary recommendation to reduce supply-chain risk from moved/compromised tags. Verify the SHA comes from the action’s official repo (not a fork). [1]
  • Audit the action/workflow source (including what it does with your repo contents and secrets) before adopting it. [1]
  • If you must reference by tag, do so only if you trust the creator (GitHub notes tags can be moved/deleted if the repo is compromised; “Verified creator” is a useful signal). [1]
  • Apply the same rules to reusable workflows you call via OWNER/REPO/.github/workflows/workflow.yml@REF—GitHub explicitly says the third-party action guidance also applies to third-party reusable workflows. [1]
  • Use Dependabot version updates to keep referenced actions and reusable workflows up to date. [1]
  • Enforce governance with “allowed actions and reusable workflows” policies, including:
    • Require SHA pinning (enforcement can make unpinned workflows fail). [2]
    • Allowlist/denylist specific actions/workflows (including explicit blocking). [2]
    • Use patterns that match how you reference actions (OWNER/REPO@TAG-or-SHA) and reusable workflows (OWNER/REPO/PATH/FILENAME@TAG-or-SHA). [3]

Sources

[1] GitHub Docs — Security hardening for GitHub Actions (Secure use reference) (docs.github.com)
[2] GitHub Changelog (2025‑08‑15) — Actions policy now supports blocking and SHA pinning actions (github.blog)
[3] GitHub Enterprise Cloud Docs — Enterprise policies: allowed actions & reusable workflows / require SHA pinning; syntax examples (docs.github.com)

Citations:


Pin reusable workflow to a commit SHA instead of @master.

GitHub's official security guidance recommends pinning third-party actions and reusable workflows to full-length commit SHAs (immutable references) to reduce supply-chain risk. Using @master creates a mutable reference that can change unexpectedly if the upstream repository is modified or compromised. Replace @master with the specific commit SHA of the workflow version you intend to use.

Suggested fix
-    uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master
+    uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@<commit-sha>

Also applies to: 37-37

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/backport.yml at line 22, Replace the mutable reference
"openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master" with an
immutable full commit SHA (e.g.
"openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@<full-commit-sha>")
in both occurrences referenced in the workflow; locate the current upstream
commit you want to pin to, copy its full 40-character SHA and substitute it for
"@master" so the reusable workflow is pinned to that exact commit.

Comment on lines +30 to +36
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.issue.pull_request.merged_at != null &&
github.event.issue.state == 'closed' &&
contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/backport')
Copy link

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

🌐 Web query:

GitHub Actions issue_comment event github.event.issue.pull_request merged_at field availability

💡 Result:

In a workflow triggered by issue_comment, github.event.issue.pull_request is not a full pull request object, so you should not expect merged_at to be present.

  • GitHub’s Actions docs call out github.event.issue.pull_request mainly as a truthy check to tell whether the comment came from a PR vs a plain issue. (docs.github.com)
  • In the underlying payload, that issue.pull_request value is only a small “PR links” object (e.g., html_url, diff_url, patch_url, etc.), not fields like merged, merged_at, etc. (matrix-org.github.io)
  • PR-only fields are generally available when the workflow is triggered by PR events (pull_request, pull_request_target), not issue_comment. (docs.github.com)

What to do instead: if you need merged_at in an issue_comment workflow, make a REST/GraphQL API call to fetch the PR by number (github.event.issue.number) and read merged_at, or trigger on pull_request (e.g., types: [closed]) and use that event payload. (docs.github.com)

Citations:


merged_at is unavailable in issue_comment events and prevents this job from running.

At Line 33, github.event.issue.pull_request.merged_at does not exist in the issue_comment event payload. The issue.pull_request object in issue_comment events contains only minimal fields (links like html_url, diff_url, patch_url), not PR status fields like merged_at. This condition will evaluate to false and block the job from executing.

Suggested fix
   backport-on-comment:
     if: >
       github.event_name == 'issue_comment' &&
       github.event.issue.pull_request &&
-      github.event.issue.pull_request.merged_at != null &&
       github.event.issue.state == 'closed' &&
       contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
       startsWith(github.event.comment.body, '/backport')

If you need to verify PR merge status, make a REST or GraphQL API call to fetch the full PR object by number.

📝 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
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.issue.pull_request.merged_at != null &&
github.event.issue.state == 'closed' &&
contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/backport')
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.issue.state == 'closed' &&
contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/backport')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/backport.yml around lines 30 - 36, The condition uses
github.event.issue.pull_request.merged_at which is not present on issue_comment
events; remove that check from the if and instead let the workflow trigger on
the comment and then fetch the full PR to verify merge status (use the PR number
from github.event.issue.pull_request and call the REST/GraphQL API in a step)
before proceeding with the backport logic; keep the existing checks for event
name, author association (contains(...)) and
startsWith(github.event.comment.body, '/backport'), and add a step that calls
the GitHub API to confirm the PR's merged state (e.g., check the PR resource's
merged boolean) before running backport steps.

secrets:
app_id: ${{ secrets.OPENWISP_BOT_APP_ID }}
private_key: ${{ secrets.OPENWISP_BOT_PRIVATE_KEY }}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the extra trailing blank line to satisfy YAML lint.

Static analysis reports an empty-lines violation at Line 44.

🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 44-44: too many blank lines (1 > 0)

(empty-lines)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/backport.yml at line 44, Remove the extra trailing blank
line in the backport.yml workflow file to satisfy YAML lint’s empty-lines rule;
open backport.yml and delete the blank line at the end of the file so the file
ends immediately after the last non-empty line.

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.

2 participants