Skip to content

Commit 094eb62

Browse files
committed
Implement branch deletion & re-creation
1 parent 3db69d2 commit 094eb62

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

.github/workflows/spec-update.yaml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ jobs:
5353
id: branch
5454
run: |
5555
BRANCH="spec-update/$CHOICE/$REF"
56+
if git ls-remote --exit-code origin refs/heads/$BRANCH >/dev/null 2>&1; then
57+
echo "Branch '$BRANCH' exists on remote, deleting it..."
58+
git push origin --delete $BRANCH
59+
fi
5660
git checkout -b $BRANCH
5761
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
5862
@@ -101,40 +105,32 @@ jobs:
101105
id: generate
102106
if: steps.spec_diff.outputs.spec_diff == 'true'
103107
run: |
104-
echo "success=false" >> "$GITHUB_OUTPUT"
105-
mvn process-sources -Dgenerate ${{ env.MVN_MULTI_THREADED_ARGS }}
106-
echo "success=true" >> "$GITHUB_OUTPUT"
107-
108-
- name: "Compile Client"
109-
id: compile
110-
if: steps.spec_diff.outputs.spec_diff == 'true'
111-
run: |
112-
mvn test-compile ${{ env.MVN_MULTI_THREADED_ARGS }}
108+
mvn process-test-sources -Dgenerate ${{ env.MVN_MULTI_THREADED_ARGS }}
113109
114110
- name: "Push changes"
115111
id: push
116112
if: steps.spec_diff.outputs.spec_diff == 'true'
117113
run: |
118-
# TODO: decide if timestamp is necessary
119-
# TIME=$(date '+%d-%m--%H:%M')
120-
121114
git add .
122-
git commit -m "Update $CHOICE on $REF at $TIME"
115+
git commit -m "Update $CHOICE based on $REF"
123116
git push origin $BRANCH
124117
125118
- name: "Create pull request"
126119
if: ${{ env.CREATE_PR }}
127120
run: |
128121
gh pr create --base main --head ${{ steps.push.outputs.branch }} --title "feat: [DevOps] Update $CHOICE Specification"
129122
123+
- name: "Compile Client"
124+
id: compile
125+
if: steps.spec_diff.outputs.spec_diff == 'true'
126+
run: |
127+
mvn test-compile ${{ env.MVN_MULTI_THREADED_ARGS }}
128+
130129
- name: "Handle failure"
131130
if: ${{ failure() }}
132131
run: |
133132
echo "Failed to update $CHOICE specification file"
134133
echo "File download outcome: ${{ steps.download.outcome }}"
135134
echo "Spec file contained changes: ${{ steps.spec_diff.output.spec_diff }}"
136-
echo "Client generation outcome: ${{ steps.generate.output.success }}"
135+
echo "Client generation outcome: ${{ steps.generate.outcome }}"
137136
echo "Client compilation outcome: ${{ steps.compile.outcome }}"
138-
139-
# TODO: Delete branch?
140-
# git push origin --delete ${{ steps.push.outputs.branch }}

0 commit comments

Comments
 (0)