-
-
Notifications
You must be signed in to change notification settings - Fork 216
[ci] Added automated backport workflow #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||
| name: Backport fixes to stable branch | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| push: | ||||||||||||||
| branches: | ||||||||||||||
| - master | ||||||||||||||
| issue_comment: | ||||||||||||||
| types: [created] | ||||||||||||||
|
|
||||||||||||||
| concurrency: | ||||||||||||||
| group: backport-${{ github.workflow }}-${{ github.ref }} | ||||||||||||||
| cancel-in-progress: false | ||||||||||||||
|
|
||||||||||||||
| permissions: | ||||||||||||||
| contents: write | ||||||||||||||
| pull-requests: write | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| backport-on-push: | ||||||||||||||
| if: github.event_name == 'push' | ||||||||||||||
| uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin the external reusable workflow to a commit SHA, not the mutable "Pinning an action to a full-length commit SHA is currently the only way to use an action as an immutable release." A tag (or branch name) can be moved or deleted if a bad actor gains access to the upstream repository, and the same principles apply to third-party reusable workflows. Additionally, when re-running a workflow that uses a reusable workflow and the reference is not a SHA, re-running all jobs will use the reusable workflow from the specified reference at that point in time, making reruns non-deterministic. 🔧 Proposed fix (apply to both lines 22 and 37)- uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master
+ uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@<full-commit-sha> # `@master` as of <date>Retrieve the current SHA with: gh api repos/openwisp/openwisp-utils/commits/master --jq '.sha'Also applies to: 37-37 🤖 Prompt for AI Agents |
||||||||||||||
| with: | ||||||||||||||
| commit_sha: ${{ github.sha }} | ||||||||||||||
| secrets: | ||||||||||||||
| app_id: ${{ secrets.OPENWISP_BOT_APP_ID }} | ||||||||||||||
| private_key: ${{ secrets.OPENWISP_BOT_PRIVATE_KEY }} | ||||||||||||||
|
|
||||||||||||||
| backport-on-comment: | ||||||||||||||
| if: > | ||||||||||||||
| github.event_name == 'issue_comment' && | ||||||||||||||
| github.event.issue.pull_request && | ||||||||||||||
| github.event.issue.pull_request.merged_at != null && | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In an However, for To get Sources Remove In 🔧 Proposed fix 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')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| github.event.issue.state == 'closed' && | ||||||||||||||
| contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) && | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider whether The guard currently restricts comment-triggered backports to 🔧 Proposed fix (if collaborators should be allowed)- contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) &&
+ contains(fromJSON('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.comment.author_association) &&📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| startsWith(github.event.comment.body, '/backport') | ||||||||||||||
| uses: openwisp/openwisp-utils/.github/workflows/reusable-backport.yml@master | ||||||||||||||
| with: | ||||||||||||||
| pr_number: ${{ github.event.issue.number }} | ||||||||||||||
| comment_body: ${{ github.event.comment.body }} | ||||||||||||||
| secrets: | ||||||||||||||
| app_id: ${{ secrets.OPENWISP_BOT_APP_ID }} | ||||||||||||||
| private_key: ${{ secrets.OPENWISP_BOT_PRIVATE_KEY }} | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concurrency group key collapses all runs into one queue.
github.refforissue_commentevents is always the default branch. That is the same value thepushtrigger produces when a commit lands onmaster/main, so every run — push-triggered or comment-triggered, regardless of which PR is being backported — shares a single concurrency group. Withcancel-in-progress: falsethey all queue sequentially, meaning two concurrent/backportrequests on unrelated PRs (e.g. targeting different stable branches) unnecessarily block each other.Scope the key more narrowly so unrelated runs can proceed in parallel:
🔧 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents