Skip to content

Commit 636c9b9

Browse files
committed
casc
1 parent d267a24 commit 636c9b9

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

.github/actions/push-changes/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ runs:
9696
git commit -m '${{ inputs.commit-message }}'
9797
git pull --rebase origin ${{ github.head_ref || github.ref }}
9898
git push
99-
working-directory: ${{ inputs.working-directory }}
99+
working-directory: ${{ inputs.working-directory }}

.github/workflows/promote-branch.yml

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
runs-on: ubuntu-latest
5050
outputs:
5151
target-branch: ${{ steps.compose-target-branch.outputs.target-branch }}
52+
target-branch-exists: ${{ steps.validate-target-branch.outputs.target-branch-exists }}
5253
steps:
5354
- name: 'Compose target branch name'
5455
id: compose-target-branch
@@ -59,9 +60,30 @@ jobs:
5960
target_branch="release/${{ needs.versioning.outputs.friendly-version }}"
6061
fi
6162
62-
echo "Target branch: $target_branch"
63+
echo "Target branch name: $target_branch"
6364
6465
echo "target-branch=$target_branch" >> $GITHUB_OUTPUT
66+
- name: 'Validate target branch in origin'
67+
id: validate-target-branch
68+
env:
69+
target-branch: ${{ needs.workflow-variables.outputs.target-branch }}
70+
run: |
71+
set +e
72+
73+
git ls-remote --exit-code --heads origin ${{ env.target-branch }}
74+
75+
if [[ $? -eq 0 ]]; then
76+
echo "Target branch exist: ${{ env.target-branch }}"
77+
target_branch_exists="true"
78+
else
79+
echo "Target branch does not exist: ${{ env.target-branch }}"
80+
target_branch_exists="false"
81+
fi
82+
83+
echo "target-branch-exists=$target_branch_exists" >> $GITHUB_OUTPUT
84+
85+
set -e
86+
6587
validate-promotion:
6688
name: 'Validate promotion'
6789
needs: [ versioning, workflow-variables ]
@@ -76,20 +98,28 @@ jobs:
7698
run: |
7799
echo "Invalid promotion type: ${{ inputs.promotion-type }}"
78100
exit 1
79-
- name: 'Check source branch'
101+
- name: 'Validate source branch'
80102
if: ${{ (env.isdevelopment-branch == 'false') && (env.is-maintenance-branch == 'false') }}
81103
run: |
82104
echo "Invalid source branch: ${{ github.ref_name }}"
83105
exit 1
84-
- name: 'Validate target branch'
85-
env:
86-
target-branch: ${{ needs.workflow-variables.outputs.target-branch }}
87-
run: |
88-
set +e
89-
90-
git ls-remote --exit-code --heads origin ${{ env.target-branch }}
91106
92-
if [[ $? -eq 0 ]]; then
93-
echo "Target branch exist: ${{ env.target-branch }}"
94-
exit 1
95-
fi
107+
promote-branch:
108+
name: 'Promote branch ${{ }}'
109+
needs: [ workflow-variables, validate-promotion ]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
113+
uses: actions/checkout@v4
114+
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
115+
uses: actions/setup-dotnet@v4
116+
with:
117+
dotnet-version: ${{ env.dotnet-sdk-version }}
118+
- name: 'Create target branch'
119+
if: ${{ needs.workflow-variables.outputs.target-branch-exists == 'false' }}
120+
run: |
121+
git config user.name "$(git log -n 1 --pretty=format:%an)"
122+
git config user.email "$(git log -n 1 --pretty=format:%ae)"
123+
git fetch origin
124+
git checkout -b ${{ needs.workflow-variables.outputs.target-branch }} origin/HEAD
125+
git push

0 commit comments

Comments
 (0)