|
| 1 | +name: Chore Release PR Automation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, reopened] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + chore_release_branches: |
| 9 | + description: 'Comma-separated list of chore release branches' |
| 10 | + required: true |
| 11 | + default: 'chore_release-8.5.0,chore_release-pd-8.5.0' |
| 12 | + target_branch: |
| 13 | + description: 'Target branch for testing' |
| 14 | + required: true |
| 15 | + default: 'chore_release-8.5.0' |
| 16 | + |
| 17 | +jobs: |
| 18 | + handle-chore-release: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: '3.10' |
| 29 | + |
| 30 | + - name: Set variables for branch and target |
| 31 | + id: set-vars |
| 32 | + run: | |
| 33 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 34 | + echo "chore_release_branches=${{ github.event.inputs.chore_release_branches }}" >> $GITHUB_ENV |
| 35 | + echo "target_branch=${{ github.event.inputs.target_branch }}" >> $GITHUB_ENV |
| 36 | + else |
| 37 | + echo "chore_release_branches=${{ secrets.CHORE_RELEASE_BRANCHES }}" >> $GITHUB_ENV |
| 38 | + echo "target_branch=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV |
| 39 | + fi |
| 40 | +
|
| 41 | + - name: Determine downstream chore release PRs |
| 42 | + id: downstream |
| 43 | + run: | |
| 44 | + python scripts/chore_release_pr_gen.py \ |
| 45 | + --branch-list "$chore_release_branches" \ |
| 46 | + --target-branch "$target_branch" \ |
| 47 | + --output-file "$GITHUB_ENV" |
| 48 | +
|
| 49 | + - name: Display summary of inputs and downstream branches |
| 50 | + run: | |
| 51 | + # Set variables for display, using dash if empty |
| 52 | + chore_release_branches_display="$chore_release_branches" |
| 53 | + if [ -z "$chore_release_branches_display" ]; then chore_release_branches_display='-'; fi |
| 54 | + target_branch_display="$target_branch" |
| 55 | + if [ -z "$target_branch_display" ]; then target_branch_display='-'; fi |
| 56 | + downstream_branches_display="$downstream_branches" |
| 57 | + if [ -z "$downstream_branches_display" ]; then downstream_branches_display='-'; fi |
| 58 | +
|
| 59 | + echo "| Input | Value |" >> $GITHUB_STEP_SUMMARY |
| 60 | + echo "|------------------------|--------------------------|" >> $GITHUB_STEP_SUMMARY |
| 61 | + echo "| chore_release_branches | $chore_release_branches_display |" >> $GITHUB_STEP_SUMMARY |
| 62 | + echo "| target_branch | $target_branch_display |" >> $GITHUB_STEP_SUMMARY |
| 63 | + echo "| downstream_branches | $downstream_branches_display |" >> $GITHUB_STEP_SUMMARY |
| 64 | +
|
| 65 | + if [ "$downstream_branches_display" = "-" ]; then |
| 66 | + echo "\n### No downstream PRs to open." >> $GITHUB_STEP_SUMMARY |
| 67 | + else |
| 68 | + echo "\n### Downstream PRs should be opened for:" >> $GITHUB_STEP_SUMMARY |
| 69 | + echo "\`$downstream_branches_display\`" >> $GITHUB_STEP_SUMMARY |
| 70 | + fi |
0 commit comments