Last active
June 21, 2025 23:07
-
-
Save yokawasa/8f3d62bdd156396c6c249e389306ea6e to your computer and use it in GitHub Desktop.
Revisions
-
yokawasa revised this gist
Jun 21, 2025 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,9 @@ on: types: [opened, synchronize] env: # OpenAPI file path OPENAPI_FILE: oas/openapi.yaml # Postman Collection file path COLLECTION_FILE: postman/collections/36962762-584eb5cd-551c-4b2a-8bcc-d4ae56f2db0e.json jobs: @@ -26,7 +28,6 @@ jobs: CHANGED=$(git diff --name-only origin/main HEAD | grep "$OPENAPI_FILE" || true) echo "changed_files=$CHANGED" >> $GITHUB_OUTPUT - name: Exit if no changes detected if: steps.detect_change.outputs.changed_files == '' run: | -
yokawasa revised this gist
Jun 21, 2025 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,6 @@ env: jobs: generate-postman-collection: runs-on: ubuntu-latest steps: -
yokawasa created this gist
Jun 20, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ name: Update Postman Collection on: pull_request: branches: [main] types: [opened, synchronize] env: OPENAPI_FILE: oas/openapi.yaml COLLECTION_FILE: postman/collections/36962762-584eb5cd-551c-4b2a-8bcc-d4ae56f2db0e.json jobs: generate-postman-collection: if: contains(github.event.pull_request.head.ref, 'feature-') runs-on: ubuntu-latest steps: - name: Checkout PR branch uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.ref }} - name: Check for changes in openapi.yaml id: detect_change run: | git fetch origin main CHANGED=$(git diff --name-only origin/main HEAD | grep "$OPENAPI_FILE" || true) echo "changed_files=$CHANGED" >> $GITHUB_OUTPUT # add step to finish the workflow if no changes are detected - name: Exit if no changes detected if: steps.detect_change.outputs.changed_files == '' run: | echo "No changes detected in oas/openapi.yaml. Exiting workflow." exit 0 - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: '18' - name: Install openapi-to-postmanv2 run: npm install -g openapi-to-postmanv2 - name: Get postman collection ID id: get_collection_id run: | if [ -f "$COLLECTION_FILE" ]; then COLLECTION_ID=$(jq -r '.info._postman_id' "$COLLECTION_FILE") echo "collection_id=$COLLECTION_ID" >> $GITHUB_OUTPUT fi - name: Generate postman collection run: | openapi2postmanv2 -s $OPENAPI_FILE \ -o $COLLECTION_FILE -p \ -O folderStrategy=Tags,parametersResolution=Example,enableOptionalParameters=false # Update collection ID if it exists if [ -n "${{ steps.get_collection_id.outputs.collection_id }}" ]; then jq --arg id "${{ steps.get_collection_id.outputs.collection_id }}" \ '.info._postman_id = $id' "$COLLECTION_FILE" > tmp.json mv tmp.json "$COLLECTION_FILE" fi - name: Commit and push generated collection run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add $COLLECTION_FILE git commit -m "chore: auto-generate postman collection from OpenAPI" git push origin HEAD:${{ github.event.pull_request.head.ref }}