|
8 | 8 | # 2. Test |
9 | 9 | # 3. Merge |
10 | 10 |
|
| 11 | +# Tested to Trigger when a developer merges PR from github UI |
| 12 | +# to test if triggers on programmatic merge: `gh pr merge boarding-auto --auto --delete-branch --squash` |
| 13 | + |
| 14 | +name: Merge RT in Release |
11 | 15 | # Release Train (RT) has All changes needed for Release |
12 | 16 | # We Test RT, and do auto merge if CI Checks Pass |
13 | 17 |
|
14 | 18 | on: |
15 | 19 | pull_request: |
| 20 | + # When a pull request merges, the pull request is automatically closed. |
| 21 | + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges |
16 | 22 | types: [closed] |
17 | | - # push: |
18 | | - # tags: |
19 | | - # - merge-rt-in-release |
| 23 | + branches: # ALLOWED Base Branches |
| 24 | + - release-train |
20 | 25 |
|
21 | 26 | jobs: |
| 27 | + # RUN Job when 'boarding-auto --> 'release-train' PR is merged |
22 | 28 | merge_rt_in_release: |
23 | | - # When 'boarding-n-auto-release --> 'release-train' PR is merged |
24 | | - if: ${{ github.event.pull_request.merged == true && |
25 | | - github.event.pull_request.head.ref == 'boarding-n-auto-release' && \ |
26 | | - github.event.pull_request.base.ref == 'release-train' }} |
| 29 | + # ALLOWED Head Branches |
| 30 | + # if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'boarding-auto') |
| 31 | + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true |
| 32 | + |
27 | 33 | runs-on: ubuntu-latest |
28 | 34 | env: |
29 | 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
30 | 36 | TRAIN: 'release-train' |
31 | 37 | RELEASE_BR: 'release' |
32 | 38 | MAIN_BR: 'master' |
33 | 39 | steps: |
| 40 | + - run: "echo \"[DEBUG] HEAD: '${{ github.head_ref }}', should be 'boarding-auto'\"" |
| 41 | + - run: "echo \"[DEBUG] BASE: '${{ github.base_ref }}', should be 'release-train'\"" |
| 42 | + |
34 | 43 | - uses: actions/checkout@v4 |
35 | 44 | with: |
36 | 45 | fetch-depth: 0 # 0 indicates all history for all branches and tags. |
37 | 46 | set-safe-directory: '' # `git config --global --add safe.directory <path>` |
38 | 47 | token: '${{ secrets.GH_TOKEN }}' |
39 | 48 |
|
40 | 49 | # Track the remote branches |
41 | | - - run: git branch --track "${{ env.TRAIN }}" "origin/${{ env.TRAIN }}" |
42 | | - - run: git branch --track "${{ env.RELEASE_BR }}" "origin/${{ env.RELEASE_BR }}" |
| 50 | + - run: git branch --track "${{ env.TRAIN }}" "origin/${{ env.TRAIN }}" || echo "Branch '${{ env.TRAIN }}' already exists" |
| 51 | + - run: git branch --track "${{ env.RELEASE_BR }}" "origin/${{ env.RELEASE_BR }}" || echo "Branch '${{ env.RELEASE_BR }}' already exists" |
43 | 52 |
|
44 | 53 | ############## PR ############## |
45 | 54 | - name: "Create PR 'head': ${{ env.TRAIN }} --> 'base': ${{ env.RELEASE_BR }}" |
|
0 commit comments