Skip to content

Commit d752cf0

Browse files
committed
Add Comments
1 parent 468d860 commit d752cf0

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

.github/workflows/spec-update.yaml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,6 @@ jobs:
5454
with:
5555
token: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
5656

57-
- name: "Checkout or Create Branch"
58-
id: branch
59-
env:
60-
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
61-
run: |
62-
BRANCH="spec-update/$CHOICE/$REF"
63-
if gh pr list --head $BRANCH --json number -q '.[].number' | grep -q .; then
64-
echo "An open PR already exists for this branch. Please close the PR first before re-running the workflow."
65-
exit 1
66-
fi
67-
68-
if git ls-remote --exit-code origin refs/heads/$BRANCH >/dev/null 2>&1; then
69-
echo "Branch '$BRANCH' exists on remote, deleting it..."
70-
git push origin --delete $BRANCH
71-
fi
72-
git checkout -b $BRANCH
73-
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
74-
7557
- name: "Download specification file"
7658
id: download
7759
env:
@@ -105,6 +87,28 @@ jobs:
10587
echo "spec_diff=false" >> "$GITHUB_OUTPUT"
10688
fi
10789
90+
- name: "Checkout or Create Branch"
91+
description: |
92+
Always create a new branch to ensure we generate from a clean state.
93+
In case a PR exist we can't delete and re-create the branch (without closing the PR first).
94+
So the workflow will exist in this case.
95+
id: branch
96+
env:
97+
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
98+
run: |
99+
BRANCH="spec-update/$CHOICE/$REF"
100+
if gh pr list --head $BRANCH --json number -q '.[].number' | grep -q .; then
101+
echo "An open PR already exists for this branch. Please close the PR first before re-running the workflow."
102+
exit 1
103+
fi
104+
105+
if git ls-remote --exit-code origin refs/heads/$BRANCH >/dev/null 2>&1; then
106+
echo "Branch '$BRANCH' exists on remote, deleting it..."
107+
git push origin --delete $BRANCH
108+
fi
109+
git checkout -b $BRANCH
110+
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
111+
108112
- name: "Setup java"
109113
uses: actions/setup-java@v4
110114
if: steps.spec_diff.outputs.spec_diff == 'true'
@@ -140,7 +144,7 @@ jobs:
140144
Update $CHOICE specification file based on $REF.
141145
142146
This PR was created automatically by the [spec-update workflow](https://github.com/SAP/ai-sdk-java/actions/workflows/spec-update.yaml).
143-
You can commit on top of this branch, but keep in mind that re-running the action will overwrite your changes.
147+
You can commit on top of this branch, but as long as this PR is open the action can't be re-run.
144148
145149
Before merging, make sure to update tests and release notes, if necessary.
146150
@@ -154,6 +158,9 @@ jobs:
154158
- name: "Compile and Test"
155159
id: compile
156160
if: steps.spec_diff.outputs.spec_diff == 'true'
161+
description: |
162+
Compilation can easily fail e.g. from re-namings and has to be fixed manually.
163+
Thus this action raises the PR anyway and only reports success or failure of compilation and testing.
157164
run: |
158165
if mvn test-compile ${{ env.MVN_MULTI_THREADED_ARGS }} ; then
159166
echo "compilation_result=success" >> "$GITHUB_OUTPUT"
@@ -166,10 +173,10 @@ jobs:
166173
echo "compilation_result=failure" >> "$GITHUB_OUTPUT"
167174
fi
168175
169-
- name: "Handle failure"
170-
if: ${{ failure() }}
176+
- name: "Print Summary"
177+
if: ${{ always() }}
171178
run: |
172-
echo "Failed to update $CHOICE specification file"
179+
echo "Branch creation: ${{ steps.branch.outcome }}"
173180
echo "File download outcome: ${{ steps.download.outcome }}"
174181
echo "Spec file contained changes: ${{ steps.spec_diff.outputs.spec_diff }}"
175182
echo "Client generation outcome: ${{ steps.generate.outcome }}"

0 commit comments

Comments
 (0)