Skip to content

Commit 382e967

Browse files
authored
Update OpenAPI generation workflow to correctly handle change detection and commit logic (#40)
1 parent 0e3df41 commit 382e967

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

.github/workflows/generate-openapi.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,29 @@ jobs:
3737

3838
- name: Run SDK generation script
3939
run: sh ./generate_openapi.sh
40+
41+
- name: Restore .NET tools
42+
run: dotnet tool restore
4043

4144
- name: Check for changes
4245
id: check_changes
4346
run: |
44-
git diff --exit-code || echo "changes"
45-
46-
- name: Commit changes
47-
if: steps.check_changes.outputs.changes == 'changes'
48-
run: |
49-
git config user.name "github-actions"
50-
git config user.email "github-actions@users.noreply.github.com"
51-
git checkout -b feat/sdk-update-$(date +'%Y%m%d')
52-
git add .
53-
git commit -m "Update SDK from OpenAPI specs"
54-
55-
- name: Push changes to a new branch
56-
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
run: |
59-
git push origin feat/sdk-update-$(date +'%Y%m%d')
60-
47+
if ! git diff --exit-code; then
48+
echo "changes=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "changes=false" >> $GITHUB_OUTPUT
51+
fi
6152
- name: Create a pull request
53+
if: steps.check_changes.outputs.changes == 'true'
6254
id: create_pr
6355
uses: peter-evans/create-pull-request@v7
6456
with:
6557
token: ${{ secrets.GITHUB_TOKEN }}
66-
branch: sdk-update-$(date +'%Y%m%d')
58+
branch: "feat/sdk-update"
59+
branch-suffix: timestamp
6760
title: "OpenAPI SDK Update"
6861
body: "This PR updates the SDK based on the latest OpenAPI specifications."
62+
commit-message: "Update SDK from OpenAPI specs"
6963

7064
- name: Output PR URL
7165
if: steps.create_pr.outputs.pull-request-url != ''

0 commit comments

Comments
 (0)