Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions .github/workflows/on_comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: "On Comment"

on:
issue_comment:
types: [created]

permissions:
contents: write
issues: write
pull-requests: write

jobs:
# This job always runs to prevent GHA from marking the run as failed when
# all other jobs are skipped.
noop:
runs-on: ubuntu-latest
steps:
- run: echo "No-op"

parse_comment:
runs-on: ubuntu-latest
if: |
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
outputs:
command: ${{ steps.parse.outputs.command }}
issue_number: ${{ steps.parse.outputs.issue_number }}
pr_number: ${{ steps.parse.outputs.pr_number }}
backports: ${{ steps.parse.outputs.backports }}
steps:
- name: Parse comment
id: parse
env:
COMMENT_BODY: ${{ github.event.comment.body }}
IS_PR: "${{ github.event.issue.pull_request != null }}"
EVENT_NUMBER: "${{ github.event.issue.number }}"
HAS_RELEASE_LABEL: "${{ contains(github.event.issue.labels.*.name, 'type: release') }}"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "$IS_PR" = "false" ] && [ "$HAS_RELEASE_LABEL" = "true" ]; then
issue_number=$EVENT_NUMBER
if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-rc([[:space:]]|$)'; then
echo "command=create-rc" >> "$GITHUB_OUTPUT"
echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then
echo "command=prepare" >> "$GITHUB_OUTPUT"
echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/process-backports([[:space:]]|$)'; then
echo "command=process-backports" >> "$GITHUB_OUTPUT"
echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/add-backports([[:space:]]|$)'; then
args=$(echo "$COMMENT_BODY" | grep -E '^[[:space:]]*/add-backports([[:space:]]|$)' | sed -E 's/^[[:space:]]*\/add-backports[[:space:]]*//')
args=$(echo "$args" | sed -e 's/^[[:space:],]*//' -e 's/[[:space:],]*$//')
csv=$(echo "$args" | sed -E 's/[[:space:],]+/ /g' | tr ' ' ',')
if [ -n "$csv" ]; then
echo "command=add-backports" >> "$GITHUB_OUTPUT"
echo "backports=$csv" >> "$GITHUB_OUTPUT"
echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
else
echo "command=none" >> "$GITHUB_OUTPUT"
echo "Error: No PRs specified for add-backports." >&2
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
-f "content=-1"
fi
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/promote([[:space:]]|$)'; then
echo "command=promote" >> "$GITHUB_OUTPUT"
echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT"
else
echo "command=none" >> "$GITHUB_OUTPUT"
fi
elif [ "$IS_PR" = "true" ]; then
pr_number=$EVENT_NUMBER
if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/backport([[:space:]]|$)'; then
echo "command=pr-backport" >> "$GITHUB_OUTPUT"
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
else
echo "command=none" >> "$GITHUB_OUTPUT"
fi
else
echo "command=none" >> "$GITHUB_OUTPUT"
fi

call_create_rc:
needs: parse_comment
if: needs.parse_comment.outputs.command == 'create-rc'
uses: ./.github/workflows/release_create_rc.yaml
with:
issue: ${{ needs.parse_comment.outputs.issue_number }}
comment_id: "${{ github.event.comment.id }}"
secrets: inherit

call_prepare:
needs: parse_comment
if: needs.parse_comment.outputs.command == 'prepare'
uses: ./.github/workflows/release_prepare.yaml
with:
issue: ${{ needs.parse_comment.outputs.issue_number }}
secrets: inherit

call_add_backports:
needs: parse_comment
if: |
needs.parse_comment.outputs.command == 'add-backports' ||
needs.parse_comment.outputs.command == 'pr-backport'
uses: ./.github/workflows/release_add_backports.yaml
with:
prs: ${{ needs.parse_comment.outputs.command == 'pr-backport' && needs.parse_comment.outputs.pr_number || needs.parse_comment.outputs.backports }}
issue: ${{ needs.parse_comment.outputs.issue_number }}
secrets: inherit

call_process_backports_after_add:
needs: [parse_comment, call_add_backports]
if: needs.parse_comment.outputs.command == 'add-backports'
uses: ./.github/workflows/release_process_backports.yaml
with:
issue: ${{ needs.parse_comment.outputs.issue_number }}
comment_id: "${{ github.event.comment.id }}"
secrets: inherit

call_process_backports_only:
needs: parse_comment
if: needs.parse_comment.outputs.command == 'process-backports'
uses: ./.github/workflows/release_process_backports.yaml
with:
issue: ${{ needs.parse_comment.outputs.issue_number }}
comment_id: "${{ github.event.comment.id }}"
secrets: inherit

call_promote:
needs: parse_comment
if: needs.parse_comment.outputs.command == 'promote'
uses: ./.github/workflows/release_promote_rc.yaml
with:
issue: ${{ needs.parse_comment.outputs.issue_number }}
secrets: inherit
105 changes: 0 additions & 105 deletions .github/workflows/on_issue_comment.yaml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/on_pr_closed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "On PR Closed"

on:
pull_request:
types: [closed]

permissions:
contents: read
issues: read
pull-requests: read

jobs:
# This job always runs to prevent GHA from marking the run as failed when
# all other jobs are skipped.
noop:
runs-on: ubuntu-latest
steps:
- run: echo "No-op"

check_if_backport:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
outputs:
should_process: ${{ steps.check.outputs.should_process }}
steps:
- name: Check if PR is a backport candidate
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
# Check if there is any active release issue
ACTIVE_ISSUES=$(gh issue list --repo ${{ github.repository }} --label "type: release" --state open --json number)
if [ "$ACTIVE_ISSUES" = "[]" ] || [ -z "$ACTIVE_ISSUES" ]; then
echo "No active release tracking issue found. Skipping."
echo "should_process=false" >> "$GITHUB_OUTPUT"
exit 0
fi

# Check if PR has "/backport" in comments (only comments, not body)
PR_DATA=$(gh pr view "$PR_NUMBER" --repo ${{ github.repository }} --json comments)

if echo "$PR_DATA" | jq -r '.comments[].body' | grep -qE '^[[:space:]]*/backport([[:space:]]|$)'; then
echo "Found /backport comment. Proceeding."
echo "should_process=true" >> "$GITHUB_OUTPUT"
else
echo "No /backport comment found. Skipping."
echo "should_process=false" >> "$GITHUB_OUTPUT"
fi

process_backports:
needs: check_if_backport
if: needs.check_if_backport.outputs.should_process == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-version: 1.20.0

- name: Configure Git Identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Process Backports
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
bazel run //tools/private/release -- on-pr-merged \
"$PR_NUMBER" \
--remote origin \
--no-dry-run
58 changes: 58 additions & 0 deletions .github/workflows/release_add_backports.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Release: Add Backports"

on:
workflow_dispatch:
inputs:
prs:
description: 'CSV list of PR numbers to add (e.g., 123,456)'
required: true
type: string
issue:
description: 'The Release Tracking Issue Number (optional)'
required: false
type: string
workflow_call:
inputs:
prs:
description: 'CSV list of PR numbers to add (e.g., 123,456)'
required: true
type: string
issue:
description: 'The Release Tracking Issue Number (optional)'
required: false
type: string

permissions:
issues: write

jobs:
add_backports:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-version: 1.20.0

- name: Add Backports to Tracking Issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRS: ${{ inputs.prs }}
ISSUE: ${{ inputs.issue }}
run: |
ARGS=()
if [ -n "$ISSUE" ]; then
ARGS+=("--issue=$ISSUE")
fi

# Convert CSV to array
IFS=',' read -r -a pr_array <<< "$PRS"

bazel run //tools/private/release -- add-backports \
"${pr_array[@]}" \
"${ARGS[@]}"
Loading