Skip to content

Commit 929a13a

Browse files
CLOUDP-262507: Create Github Action that publishes the latest OpenAPI release as a Postman Collection (#88)
1 parent d6a7718 commit 929a13a

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Postman Release
2+
on:
3+
# Enabled by CLOUDP-262512
4+
# schedule:
5+
# - cron: '0 0 10 ? * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
release-postman:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Build and upload Collection
15+
working-directory: ./tools/postman
16+
env:
17+
BASE_URL: ${{ secrets.BASE_URL }}
18+
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
19+
WORKSPACE_ID: ${{ secrets.WORKSPACE_ID }}
20+
run: |
21+
make build_and_upload

tools/postman/scripts/transform-for-api.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ echo "Wrapping Collection in \"collection\" tag"
3030
jq '{"collection": .}' "$COLLECTION_FILE_NAME" > intermediateCollectionWrapped.json
3131

3232
echo "Disabling query params by default"
33-
jq '(.. | select(.request? != null).request.url.query.[].disabled) = true ' intermediateCollectionWrapped.json > intermediateCollectionDisableQueryParam.json
33+
jq '(.. | select(.request? != null).request.url.query[].disabled) = true ' intermediateCollectionWrapped.json > intermediateCollectionDisableQueryParam.json
3434

3535
# This is to be removed because it is autogenerated when a new collection is created
3636
echo "Removing _postman_id"
@@ -40,7 +40,7 @@ echo "Updating name with version"
4040
jq '.collection.info.name = "MongoDB Atlas Administration API '"${current_api_revision}"'"' intermediateCollectionNoPostmanID.json > intermediateCollectionWithName.json
4141

4242
echo "Updating baseUrl"
43-
jq '.collection.variable.[0].value = "'"${BASE_URL}"'"' intermediateCollectionWithName.json > intermediateCollectionWithBaseURL.json
43+
jq '.collection.variable[0].value = "'"${BASE_URL}"'"' intermediateCollectionWithName.json > intermediateCollectionWithBaseURL.json
4444

4545
if [ "$USE_ENVIRONMENT_AUTH" = "false" ]; then
4646
echo "Adding auth variables"

tools/postman/scripts/upload-collection.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if [ "$collection_exists" = "false" ]; then
4747
else
4848
# Find collection ID and update collection
4949
echo "Updating remote collection ${current_collection_name}"
50-
collection_id=$(jq -r '.collections | map(select(.name=="'"${current_collection_name}"'").id).[0]' "${COLLECTIONS_LIST_FILE}")
50+
collection_id=$(jq -r '.collections | map(select(.name=="'"${current_collection_name}"'").id)[0]' "${COLLECTIONS_LIST_FILE}")
5151
curl --show-error --fail --retry 5 --retry-connrefused --silent --request PUT \
5252
--location "https://api.getpostman.com/collections/${collection_id}" \
5353
--header "Content-Type: application/json" \

0 commit comments

Comments
 (0)