From d4d4e627b5a323c73cc3cf011d9cb184fb31daff Mon Sep 17 00:00:00 2001 From: Andrew Wylde Date: Wed, 4 Oct 2023 15:32:37 -0500 Subject: [PATCH] Ci/fixes (#49) * ci: adds checkout step to get-changed-files * fix: make shipit verbose * fix: GH_TOKEN precedence over GITHUB_TOKEN * fix: remove unused PR Action --- .github/actions/build/action.yaml | 62 ----------------------------- .github/workflows/generate-sdk.yaml | 17 ++++---- .github/workflows/release.yaml | 6 +-- 3 files changed, 13 insertions(+), 72 deletions(-) delete mode 100644 .github/actions/build/action.yaml diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml deleted file mode 100644 index 8f022ed..0000000 --- a/.github/actions/build/action.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: Build JS SDK -description: > - This action builds a JavaScript SDK and updates an existing PR with the generated files -inputs: - token: - required: true - description: 'The GH token for private repos' -runs: - using: composite - steps: - - name: Checkout current repo - uses: actions/checkout@v3 - with: - path: sdk - ref: ${{ github.event.pull_request.head.ref }} - - - name: Checkout OpenAPI Tools - uses: actions/checkout@v3 - with: - repository: kong/openapi-generator-config - path: openapi-generator-config - token: ${{inputs.token}} - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: "18.x" - registry-url: "https://registry.npmjs.org" - - - name: Install Dependencies - shell: bash - run: | - npm install -g @openapitools/openapi-generator-cli@2.5.2 - - - name: Create generator config - shell: bash - working-directory: sdk - run: | - shopt -s extglob - rm -r !(openapi.yaml) - cp ../openapi-generator-config/openapitools-js.json openapitools.json - cp -r ../openapi-generator-config/templates-js . - - - name: "Generate Node SDK" - shell: bash - working-directory: sdk - run: | - openapi-generator-cli generate --generator-key client - - - name: "Clean up generator files" - shell: bash - working-directory: sdk/src - run: | - rm -rf openapitools.json templates-js .openapi-generator-ignore .openapi-generator git_push.sh - - - name: Commit SDK changes to the PR - uses: EndBug/add-and-commit@v9 - with: - cwd: sdk - add: src - default_author: github_actions - message: Update SDK based on openapi.yaml changes diff --git a/.github/workflows/generate-sdk.yaml b/.github/workflows/generate-sdk.yaml index a0ba3b4..ccab1c2 100644 --- a/.github/workflows/generate-sdk.yaml +++ b/.github/workflows/generate-sdk.yaml @@ -13,12 +13,15 @@ jobs: outputs: oas-modified: ${{ steps.oas-modified.outputs.any_modified }} steps: - - name: Check if `openapi.yaml` has changed - uses: tj-actions/changed-files@v35.7.1 - id: oas-modified - with: - files: | - openapi.yaml + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check if `openapi.yaml` has changed + uses: tj-actions/changed-files@v35.7.1 + id: oas-modified + with: + files: | + openapi.yaml generate-js: name: Generate JavaScript SDK runs-on: ubuntu-latest @@ -26,7 +29,7 @@ jobs: if: needs.get-changed-files.outputs.oas-modified == 'true' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.ref }} path: actions diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 66639b5..ccd9905 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,7 +5,7 @@ on: [push] jobs: release: runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" + if: contains(github.event.head_commit.message, 'ci skip') == 'false' && contains(github.event.head_commit.message, 'skip ci') == 'false' steps: - uses: actions/checkout@v3 @@ -27,9 +27,9 @@ jobs: - name: Create Release env: - GITHUB_TOKEN: ${{ secrets.GHA_TEAM_DEVX_KONG_BOT_PAT }} + GH_TOKEN: ${{ secrets.PORTAL_JS_SDK_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN_PRIVATE_PUBLISH }} run: | yarn install --frozen-lockfile yarn build - npx auto shipit + npx auto shipit -vv