Skip to content

Commit 90357ef

Browse files
committed
Fetch version from APTRS repository and update OpenAPI.yml accordingly
1 parent 6b470dc commit 90357ef

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/generate-openapi.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ jobs:
2323
sudo apt-get update
2424
sudo apt-get install -y curl
2525
26-
# Step 3: Send Postman Collection to Postman-to-OpenAPI service
26+
# Step 3: Fetch the version from the APTRS/APTRS repository
27+
- name: Fetch Version from APTRS Repository
28+
id: get_version
29+
run: |
30+
# Get the latest release tag from APTRS/APTRS repository
31+
VERSION=$(curl --silent \
32+
--header "Accept: application/vnd.github.v3+json" \
33+
https://api.github.com/repos/APTRS/APTRS/releases/latest | \
34+
jq -r .tag_name)
35+
36+
# Set the version as an environment variable for later use
37+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
38+
39+
# Step 4: Send Postman Collection to Postman-to-OpenAPI service
2740
- name: Convert Postman Collection to OpenAPI
2841
run: |
2942
curl --request POST \
@@ -32,16 +45,21 @@ jobs:
3245
--data "$(cat APTRS.postman_collection.json)" \
3346
--output OpenAPI.yml
3447
35-
# Step 4: Update servers section using sed
48+
# Step 5: Update the version in OpenAPI.yml
49+
- name: Update Version in OpenAPI.yml
50+
run: |
51+
sed -i "s|version:.*|version: ${VERSION}|" OpenAPI.yml
52+
53+
# Step 6: Update servers section using sed
3654
- name: Update Servers Section
3755
run: |
3856
sed -i 's|url: https://live.aptrs.com|&\n description: Local Hosted Server \n - url: https://live.aptrs.com\n description: APTRS Demo Server|g' OpenAPI.yml
3957
40-
# Step 5: Commit and push OpenAPI.yml to the repository
58+
# Step 7: Commit and push OpenAPI.yml to the repository
4159
- name: Commit and Push OpenAPI.yml
4260
run: |
4361
git config --global user.name "github-actions"
4462
git config --global user.email "[email protected]"
4563
git add OpenAPI.yml
46-
git commit -m "Update OpenAPI.yml from Postman collection"
64+
git commit -m "Update OpenAPI.yml with version ${VERSION} from APTRS repository"
4765
git push

0 commit comments

Comments
 (0)