|
1 | 1 | name: Build and Deploy (Dispatch) |
2 | 2 | on: |
3 | | - push: |
4 | | - branches: |
5 | | - - master |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | + types: [closed] |
6 | 8 |
|
7 | 9 | jobs: |
8 | 10 | release-dispatch: |
| 11 | + if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == 'master') |
9 | 12 | runs-on: ubuntu-latest |
10 | 13 | steps: |
11 | | - - name: send dispatch |
| 14 | + - name: Determine version level |
| 15 | + id: level |
| 16 | + run: | |
| 17 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 18 | + # Extract labels from merged PR |
| 19 | + LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}" |
| 20 | + echo "PR Labels: $LABELS" |
| 21 | + |
| 22 | + if [[ "$LABELS" == *"major"* ]]; then |
| 23 | + echo "level=major" >> $GITHUB_OUTPUT |
| 24 | + echo "Using PR label: major" |
| 25 | + elif [[ "$LABELS" == *"minor"* ]]; then |
| 26 | + echo "level=minor" >> $GITHUB_OUTPUT |
| 27 | + echo "Using PR label: minor" |
| 28 | + else |
| 29 | + echo "level=patch" >> $GITHUB_OUTPUT |
| 30 | + echo "Using PR label default: patch" |
| 31 | + fi |
| 32 | + else |
| 33 | + # Push to master - default to patch |
| 34 | + echo "level=patch" >> $GITHUB_OUTPUT |
| 35 | + echo "Using push default: patch" |
| 36 | + fi |
| 37 | +
|
| 38 | + - name: Send dispatch |
12 | 39 | uses: peter-evans/repository-dispatch@v3 |
13 | 40 | with: |
14 | | - token: ${{ secrets.CLOUD_DEVOPS_TOKEN }} |
| 41 | + token: ${{ secrets.CLOUD_DEVOPS_TOKEN }} |
15 | 42 | repository: ${{ secrets.dispatch_repo }} |
16 | 43 | event-type: release |
| 44 | + client-payload: | |
| 45 | + { |
| 46 | + "level": "${{ steps.level.outputs.level }}", |
| 47 | + "source": "${{ github.event_name }}", |
| 48 | + "ref": "${{ github.ref }}", |
| 49 | + "sha": "${{ github.sha }}", |
| 50 | + "actor": "${{ github.actor }}" |
| 51 | + } |
0 commit comments