From 871da8b8d8213a07f54bd4727407e669fdc42673 Mon Sep 17 00:00:00 2001 From: wolf-hash Date: Sun, 10 Mar 2024 23:31:07 +0530 Subject: [PATCH 1/9] feat: python sdk generator --- .github/workflows/sdk-generator.yml | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/sdk-generator.yml diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml new file mode 100644 index 000000000..d4f5fcdfb --- /dev/null +++ b/.github/workflows/sdk-generator.yml @@ -0,0 +1,37 @@ +name: Generate Client SDKs from OpenAPI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Generate Python Client + uses: openapi-generators/openapitools-generator-action@v1 + with: + generator: python + openapi-file: docs/apidocs.swagger.json + + - name: Push Python SDK to GitHub + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + TARGET_REPO: "permify/permify-python" + run: | + git config --global user.name 'GitHub Actions Bot' + git config --global user.email '<>' + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git + git checkout -b main + rm -rf !python-sdk + git add python-sdk + git commit -m "Update Python SDK from OpenAPI changes" + git push origin main --force From d85886f115ba16fad6d40843c9f24f17c608716d Mon Sep 17 00:00:00 2001 From: wolf-hash Date: Sun, 10 Mar 2024 23:34:19 +0530 Subject: [PATCH 2/9] fix: client folder name --- .github/workflows/sdk-generator.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index d4f5fcdfb..245d34f93 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -31,7 +31,7 @@ jobs: git config --global user.email '<>' git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git git checkout -b main - rm -rf !python-sdk - git add python-sdk + rm -rf !python-client + git add python-client git commit -m "Update Python SDK from OpenAPI changes" git push origin main --force From dc5269c7cdd17140cfeb47e792f9735aefa79a46 Mon Sep 17 00:00:00 2001 From: wolf-hash Date: Sun, 10 Mar 2024 23:38:32 +0530 Subject: [PATCH 3/9] test: sdk generator --- .github/workflows/sdk-generator.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index 245d34f93..4e9d0deb1 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - main + - sdk-generator jobs: build: From bde8c7dee7f190facddad79633a204c3fc2ebe80 Mon Sep 17 00:00:00 2001 From: wolf-hash Date: Sun, 10 Mar 2024 23:39:37 +0530 Subject: [PATCH 4/9] chore: cleanup --- .github/workflows/sdk-generator.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index 4e9d0deb1..245d34f93 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -7,7 +7,6 @@ on: pull_request: branches: - main - - sdk-generator jobs: build: From 912e23c1d259b2f50050e8ab287cc7ac0f6ac9fc Mon Sep 17 00:00:00 2001 From: wolf-hash Date: Mon, 11 Mar 2024 11:29:27 +0530 Subject: [PATCH 5/9] fix: master branch --- .github/workflows/sdk-generator.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index 245d34f93..29f52c4de 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -3,10 +3,11 @@ name: Generate Client SDKs from OpenAPI on: push: branches: - - main + - master pull_request: branches: - - main + - master + workflow_dispatch: jobs: build: From 4098dad87975a0e26e5f1f39c04f5d1f61df16e7 Mon Sep 17 00:00:00 2001 From: wolf-hash Date: Mon, 11 Mar 2024 11:58:15 +0530 Subject: [PATCH 6/9] fix: github token secret name --- .github/workflows/sdk-generator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index 29f52c4de..f4f9c329c 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -25,7 +25,7 @@ jobs: - name: Push Python SDK to GitHub env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.SDK_GH_TOKEN }} TARGET_REPO: "permify/permify-python" run: | git config --global user.name 'GitHub Actions Bot' From fbd29d1fb134e60f57d12d19f1a224eb57ff8a7a Mon Sep 17 00:00:00 2001 From: thegeekywanderer Date: Wed, 13 Mar 2024 11:24:15 +0530 Subject: [PATCH 7/9] fix: pushing to remote --- .github/workflows/sdk-generator.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index f4f9c329c..77f6fa747 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -30,9 +30,9 @@ jobs: run: | git config --global user.name 'GitHub Actions Bot' git config --global user.email '<>' - git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git - git checkout -b main - rm -rf !python-client - git add python-client + git clone https://${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git temp + cp -r python-client/* temp/ + cd temp + git add . git commit -m "Update Python SDK from OpenAPI changes" - git push origin main --force + git push https://${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git main --force From b522bfeefffba63f60715d186eb14d049fa7d287 Mon Sep 17 00:00:00 2001 From: thegeekywanderer Date: Wed, 13 Mar 2024 20:34:04 +0530 Subject: [PATCH 8/9] feat: javascript sdk generator --- .github/workflows/sdk-generator.yml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index 77f6fa747..d266bb6f0 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -12,6 +12,14 @@ on: jobs: build: runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.SDK_GH_TOKEN }} + ORG_NAME: permify + SWAGGER_PATH: docs/apidocs.swagger.json + + strategy: + matrix: + language: [python, javascript] steps: - name: Checkout repository @@ -20,19 +28,18 @@ jobs: - name: Generate Python Client uses: openapi-generators/openapitools-generator-action@v1 with: - generator: python - openapi-file: docs/apidocs.swagger.json + generator: ${{ matrix.language }} + openapi-file: ${SWAGGER_PATH} + command-args: -o permify-client --git-user-id ${ORG_NAME} --git-repo-id permify-${{ matrix.language }} --api-package permify --package-name permify - - name: Push Python SDK to GitHub - env: - GITHUB_TOKEN: ${{ secrets.SDK_GH_TOKEN }} - TARGET_REPO: "permify/permify-python" + - name: Push SDK to GitHub run: | git config --global user.name 'GitHub Actions Bot' git config --global user.email '<>' - git clone https://${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git temp - cp -r python-client/* temp/ + git clone https://${GITHUB_TOKEN}@github.com/${ORG_NAME}/permify-${{ matrix.language }}.git temp + cp -r permify-client/* temp/ cd temp git add . - git commit -m "Update Python SDK from OpenAPI changes" - git push https://${GITHUB_TOKEN}@github.com/${TARGET_REPO}.git main --force + git commit -m "Update ${{ matrix.language }} SDK from OpenAPI changes" + git push https://${GITHUB_TOKEN}@github.com/${ORG_NAME}/permify-${{ matrix.language }}.git main --force + rm -rf permify-client From 090cf19504277165f9817107b6ffff90a293936d Mon Sep 17 00:00:00 2001 From: thegeekywanderer Date: Wed, 13 Mar 2024 21:03:10 +0530 Subject: [PATCH 9/9] fix: empty commit --- .github/workflows/sdk-generator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sdk-generator.yml b/.github/workflows/sdk-generator.yml index d266bb6f0..8425fc1d1 100644 --- a/.github/workflows/sdk-generator.yml +++ b/.github/workflows/sdk-generator.yml @@ -40,6 +40,6 @@ jobs: cp -r permify-client/* temp/ cd temp git add . - git commit -m "Update ${{ matrix.language }} SDK from OpenAPI changes" + git diff-index --quiet HEAD || git commit -m "Update ${{ matrix.language }} SDK from OpenAPI changes" git push https://${GITHUB_TOKEN}@github.com/${ORG_NAME}/permify-${{ matrix.language }}.git main --force rm -rf permify-client