generate-postman #31
This file contains 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 characters
name: Generate Postman Collection | |
on: | |
repository_dispatch: | |
types: [generate-postman] | |
jobs: | |
generate-postman-collection: | |
runs-on: ubuntu-latest | |
steps: | |
- id: checkout | |
name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }} | |
- id: init-git | |
name: Init GIT | |
run: | | |
git config --global user.email "info@fattureincloud.it" | |
git config --global user.name "fattureincloud-bot" | |
- id: setup-node | |
name: Setup Node.js | |
uses: actions/setup-node@v4 | |
- id: setup-libraries | |
name: Install libraries | |
run: | | |
npm install -g yarn | |
yarn global add swagger-merger openapi-to-postmanv2 | |
sudo add-apt-repository ppa:rmescandon/yq -y | |
sudo apt update | |
sudo apt install yq -y | |
- id: read-version | |
name: Read OpenAPI spec version | |
run: | | |
API_VERSION=$(yq e '.info.version' ./openapi.yaml) | |
echo "OpenAPI version: $API_VERSION" | |
echo "api_version=$API_VERSION" >> $GITHUB_ENV | |
- id: generate-postman-collection | |
name: Generate Postman Collection | |
run: | | |
echo "Resolving OpenAPI Specification to a single file..." | |
swagger-merger -i ./openapi.yaml -o ./openapi-resolved.yaml | |
echo "Generating Postman collection..." | |
openapi2postmanv2 -s ./openapi-resolved.yaml -o ./postman/fic-api.json -p -O folderStrategy=Tags,includeAuthInfoInExample=false | |
echo "Removing single file..." | |
rm ./openapi-resolved.yaml | |
- id: create-pr | |
name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
branch: "postman-${{ env.api_version }}" | |
token: "${{ secrets.FATTUREINCLOUD_BOT_TOKEN }}" | |
delete-branch: true | |
base: master | |
commit-message: "chore: postman collection for version ${{ env.api_version }}" | |
title: "Postman Collection for Version ${{ env.api_version }}" | |
body: "New Postman Collection generated by Github Action from OpenAPI Spec ${{ env.api_version }}" |