Skip to content

chore(ci): automated chore_release PR cascade #4

chore(ci): automated chore_release PR cascade

chore(ci): automated chore_release PR cascade #4

name: Chore Release PR Automation
on:
pull_request:
types: [opened, reopened]
jobs:
handle-chore-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Determine downstream chore release PRs and necessity
id: downstream
run: |
python scripts/chore_release_pr.py \
--branch-list "${{ vars.CHORE_RELEASE_BRANCHES }}" \
--target-branch "${{ github.event.pull_request.base.ref }}" \
--output-file "$GITHUB_ENV"
- name: Display summary of inputs and downstream branches
run: |
echo "| Input | Value |" >> $GITHUB_STEP_SUMMARY
echo "|------------------------------------|-------------------------------|" >> $GITHUB_STEP_SUMMARY
echo "| vars.CHORE_RELEASE_BRANCHES | ${{ vars.CHORE_RELEASE_BRANCHES }} |" >> $GITHUB_STEP_SUMMARY
echo "| github.event.pull_request.base.ref | ${{ github.event.pull_request.base.ref }} |" >> $GITHUB_STEP_SUMMARY
echo "| downstream_branches | $downstream_branches |" >> $GITHUB_STEP_SUMMARY
echo "| should_create_prs | $should_create_prs |" >> $GITHUB_STEP_SUMMARY
echo "| github.event_name | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY
echo "| github.actor | ${{ github.actor }} |" >> $GITHUB_STEP_SUMMARY
echo "\n" >> $GITHUB_STEP_SUMMARY
if [ "$downstream_branches_display" = "-" ] || [ "$should_create_prs_display" != "true" ]; then
echo "### No downstream PRs to open." >> $GITHUB_STEP_SUMMARY
else
echo "### Downstream PRs should be opened for:" >> $GITHUB_STEP_SUMMARY
echo "\`$downstream_branches_display\`" >> $GITHUB_STEP_SUMMARY
fi
- name: Open downstream PRs
if: env.should_create_prs == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for branch in $(echo "$downstream_branches" | tr ',' ' '); do
pr_url=$(gh pr create \
--base "$branch" \
--head "${{ github.event.pull_request.head.ref }}" \
--title "${{ github.event.pull_request.title }} into $branch" \
--body "Automated PR of #${{ github.event.pull_request.number }} into downstream branch: $branch." \
--assignee "${{ github.event.pull_request.user.login }}" \
--repo "$GITHUB_REPOSITORY" 2>/dev/null || true)
if [ -n "$pr_url" ]; then
echo "Opened PR to $branch: $pr_url" >> $GITHUB_STEP_SUMMARY
else
echo "PR already exists or failed for $branch" >> $GITHUB_STEP_SUMMARY
fi
done