66 promotion-type :
77 type : choice
88 options :
9- - ' release'
109 - ' preview'
11- description : ' Target branch to create.'
10+ - ' release'
11+ description : ' Promotion type.'
1212 required : true
1313
1414permissions :
2626 is-maintenance-branch : ${{ startsWith(github.ref_name, 'support') }}
2727
2828jobs :
29+ versioning :
30+ name : ' Determine assembly version'
31+ uses : ./.github/workflows/determine-version.yml
32+ with :
33+ config-file-path : ' ./.gitversion/version.yml'
34+ run-number : ${{ github.run-number }}
2935 validate-promotion :
3036 name : ' Validate promotion'
37+ needs : [versioning]
3138 runs-on : ubuntu-latest
3239 steps :
40+ - name : ' Checkout ${{ github.head_ref || github.ref }}'
41+ uses : actions/checkout@v4
3342 - name : ' Check promotion type'
43+ if : ${{ (inputs.promotion-type != 'release') && (inputs.promotion-type != 'preview') }}
3444 run : |
35- if [[ "${{ inputs.promotion-type }}" != "release" && "${{ inputs.promotion-type }}" != "preview" ]]; then
36- echo "Invalid promotion type: ${{ inputs.promotion-type }}"
37- exit 1
38- fi
45+ echo "Invalid promotion type: ${{ inputs.promotion-type }}"
46+ exit 1
3947 - name : ' Check source branch'
48+ if : ${{ (env.isdevelopment-branch == 'false') && (env.is-maintenance-branch == 'false') }}
4049 run : |
41- if [[ "!${{ env.isdevelopment-branch }} || !${{ env.is-maintenance-branch }}" ]]; then
42- echo "Source branch is required."
43- exit 1
44- fi
50+ echo "Invalid source branch: ${{ github.ref_name }}"
51+ exit 1
52+ - name : ' Validate target branch'
53+ run : |
54+ if [[ "${{ inputs.promotion-type }}" == "preview" ]]; then
55+ echo "target-branch=preview/${{ needs.versioning.outputs.friendly-version }}" >> $GITHUB_ENV
56+ else
57+ echo "target-branch=release/${{ needs.versioning.outputs.friendly-version }}" >> $GITHUB_ENV
58+ fi
59+
60+ echo "Target branch: ${{ env.target-branch }}"
61+
62+ git ls-remote --exit-code --heads origin ${{ env.target-branch }}
0 commit comments