generate-zapier #46
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 characters
| name: Generate Zapier integration | |
| on: | |
| repository_dispatch: | |
| types: [generate-zapier] | |
| jobs: | |
| generate-zapier: | |
| runs-on: ubuntu-latest | |
| env: | |
| GIT_REPO_ID: fattureincloud-zapier | |
| GIT_USER_ID: fattureincloud | |
| steps: | |
| - id: init-git | |
| name: Init GIT | |
| run: | | |
| git config --global user.email "info@fattureincloud.it" | |
| git config --global user.name "fattureincloud-bot" | |
| - id: checkout | |
| name: Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }} | |
| - id: checkout-zapier | |
| name: Checkout zapier repo | |
| env: | |
| GIT_REPO_PATH: '${{ env.GIT_USER_ID }}/${{ env.GIT_REPO_ID }}' | |
| uses: actions/checkout@v4 | |
| with: | |
| path: ./generated/zapier | |
| ref: master | |
| repository: ${{ env.GIT_REPO_PATH }} | |
| token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }} | |
| - id: setup-node | |
| name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| - id: setup-java | |
| name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'adopt' | |
| java-version: '11' | |
| - id: setup-libraries | |
| name: Install libraries | |
| run: | | |
| npm install -g yarn | |
| yarn global add @apidevtools/swagger-cli @openapitools/openapi-generator-cli standard-version | |
| sudo apt update | |
| sudo apt upgrade | |
| sudo wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64" | |
| sudo chmod +x /usr/local/bin/yq | |
| cd ./scripts/ | |
| yarn | |
| cd ../generated/zapier/scripts | |
| yarn | |
| - id: bump-zapier-integration-version | |
| name: Bump zapier version | |
| env: | |
| OPENAPI_VERSION: ${{ github.event.client_payload.version }} | |
| run: | | |
| echo "openapi_version=$OPENAPI_VERSION" | |
| cd ./generated/zapier | |
| echo 'Bumping the patch version...' | |
| standard-version --skip.tag --skip.changelog --skip.commit --release-as patch | |
| INTEGRATION_VERSION=$(yq e '.info.version' ./version.yaml) | |
| echo "integration_version=$INTEGRATION_VERSION" >> $GITHUB_ENV | |
| echo "openapi_version=$OPENAPI_VERSION" >> $GITHUB_ENV | |
| - id: delete-old-files | |
| name: Delete old files | |
| run: | | |
| rm -rf ./generated/zapier/apis | |
| rm -rf ./generated/zapier/models | |
| rm -rf ./generated/zapier/samples | |
| rm -f ./generated/zapier/operations/actions.js | |
| - id: generate-zapier-integration | |
| name: Generate zapier integration | |
| env: | |
| PACKAGE_NAME: "@fattureincloud/zapier" | |
| run: | | |
| INTEGRATION_VERSION=${{ env.integration_version }} | |
| echo "${{ env.integration_version }}" | |
| RELEASE_NOTE="\"bumping version to $INTEGRATION_VERSION\"" | |
| openapi-generator-cli generate -i ./openapi.yaml -g zapier -o ./generated/zapier/ -t ./templates/openapi-generator/zapier --additional-properties=npmName=${PACKAGE_NAME},npmVersion=${INTEGRATION_VERSION},modelPackage=models,apiPackage=apis --git-repo-id=${GIT_REPO_ID} --git-user-id=${GIT_USER_ID} --release-note=${RELEASE_NOTE} --release-note=${RELEASE_NOTE} | |
| node ./scripts/postprocess-zapier.js './generated/zapier/apis/' | |
| - id: create-pr | |
| name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| path: ./generated/zapier | |
| branch: "devel-${{ env.integration_version }}" | |
| token: "${{ secrets.FATTUREINCLOUD_BOT_TOKEN }}" | |
| delete-branch: true | |
| base: master | |
| commit-message: "chore: bumping version to ${{ env.integration_version }}" | |
| title: "Updating integration to ${{ env.integration_version }}" | |
| body: "New integration verson ${{ env.integration_version }} generated by Github Action from OpenAPI Spec ${{ env.openapi_version }}" |