Updated API from documentation release #148
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
on: | |
push: | |
paths: | |
- 'api-specs/**' | |
workflow_dispatch: | |
name: "SDK Generator Postman" | |
permissions: {} | |
jobs: | |
diff: | |
name: "Show changes" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout api reference" | |
uses: actions/checkout@v3 | |
with: | |
path: commercetools-api-reference | |
- name: "Checkout previous api reference" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 50 | |
path: commercetools-api-reference-previous | |
- name: 'Setup Java' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: '16' | |
- name: Show commit ID | |
run: echo "previous=$(git log --format='%H' --no-merges -n 1 --skip 1)" >> $GITHUB_ENV | |
working-directory: commercetools-api-reference-previous | |
- name: "Switch to previous commit" | |
run: git checkout ${{ env.previous }} | |
working-directory: commercetools-api-reference-previous | |
- name: "Install codegen" | |
run: curl -o- -s https://raw.githubusercontent.com/commercetools/rmf-codegen/main/scripts/install.sh | bash | |
- name: "Calculate diff" | |
run: rmf-codegen diff -f JSON commercetools-api-reference-previous/api-specs/api/api.raml commercetools-api-reference/api-specs/api/api.raml | |
postman: | |
name: "Generate postman collection" | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
# Get GitHub token via the CT SDKs App | |
- name: Generate GitHub token (via CT SDKs App) | |
id: generate_github_token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.CT_SDKS_APP_ID }} | |
private-key: ${{ secrets.CT_SDKS_APP_PEM }} | |
owner: ${{ github.repository_owner }} | |
- name: Get App user | |
id: get_app_user | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | |
run: | | |
export GH_APP_USER=`gh api /users/ct-sdks%5Bbot%5D | jq .id` | |
echo "email=${GH_APP_USER}+ct-sdks[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT" | |
- name: 'Setup Java' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: '16' | |
- name: "Checkout api reference" | |
uses: actions/checkout@v3 | |
with: | |
path: commercetools-api-reference | |
- name: "Checkout postman collection" | |
uses: actions/checkout@v3 | |
with: | |
repository: 'commercetools/commercetools-postman-collection' | |
path: postman | |
# Pass a personal access token (using our CT SDKs App) to be able to trigger other workflows | |
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token | |
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8 | |
token: ${{ steps.generate_github_token.outputs.token }} | |
- name: "Generate api postman collection" | |
run: sudo chmod 777 /usr/local/bin && make build | |
working-directory: postman | |
env: | |
RAML_FILE: "../commercetools-api-reference/api-specs/api/postman.raml" | |
LIB_NAME: "api" | |
- name: "Generate importapi postman collection" | |
run: sudo chmod 777 /usr/local/bin && make build | |
working-directory: postman | |
env: | |
RAML_FILE: "../commercetools-api-reference/api-specs/import/api.raml" | |
LIB_NAME: "import" | |
- name: "Generate connect postman collection" | |
run: sudo chmod 777 /usr/local/bin && make build | |
working-directory: postman | |
env: | |
RAML_FILE: "../commercetools-api-reference/api-specs/connect/api.raml" | |
LIB_NAME: "connect" | |
- name: "check pending changes" | |
run: echo "CHANGES_PENDING=`git status --porcelain -- ':(exclude)*gen.properties' | grep -c ^`" >> $GITHUB_ENV | |
working-directory: postman | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
if: env.CHANGES_PENDING != '0' && github.ref == 'refs/heads/main' | |
with: | |
repository: postman | |
branch: master | |
commit_message: "TASK: Updating Postman collection" | |
commit_author: ct-sdks[bot] <${{ steps.get_app_user.outputs.email }}> | |
commit_user_name: ct-sdks[bot] | |
commit_user_email: ${{ steps.get_app_user.outputs.email }} |