diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index 9354196..7874c34 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -8,6 +8,8 @@ on: - 'go/**' pull_request: types: [opened, synchronize, reopened] + paths: + - 'go/**' permissions: contents: read diff --git a/.github/workflows/php-generate.yml b/.github/workflows/php-generate.yml new file mode 100644 index 0000000..33a3add --- /dev/null +++ b/.github/workflows/php-generate.yml @@ -0,0 +1,81 @@ +name: '[PHP] Generate SDK' + +on: + workflow_dispatch: + inputs: + version: + description: Version (without v) + required: false + +jobs: + generate-go-sdk: + runs-on: ubuntu-latest + name: Build Lago PHP SDK + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + path: ./ + sparse-checkout: php + sparse-checkout-cone-mode: false + + - name: Checkout Lago OpenApi Repository + uses: actions/checkout@v4 + with: + path: openapi + repository: getlago/lago-openapi + token: ${{ secrets.GH_TOKEN }} + ref: main + sparse-checkout: openapi.yaml + sparse-checkout-cone-mode: false + + - name: Init API version + id: init_version + run: | + OPENAPI_VERSION=`grep ' version:' openapi/openapi.yaml | tail -n1 | cut -c 12-` + + [[ ! -z "${{ github.event.inputs.version }}" ]] && CURRENT_VERSION=${{ github.event.inputs.version }} || CURRENT_VERSION=$OPENAPI_VERSION + + # Set version into generator config + sed -i "s/API_VERSION/$CURRENT_VERSION/" php/generator/config.yaml + + echo "api_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + + - name: Generate PHP SDK + uses: openapi-generators/openapitools-generator-action@v1 + with: + generator: php + openapi-file: openapi/openapi.yaml + config-file: php/generator/config.yaml + command-args: | + -o php --git-user-id getlago --git-repo-id sdk/php + + - name: Open PR with changes on Lago SDK Repository + run: | + API_VERSION="${{ steps.init_version.outputs.api_version }}" + BRANCH_NAME="version-${API_VERSION//./-}" + COMMIT_MESSAGE="misc(php): Version v$API_VERSION" + + # Move into php folder + cd php + + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + # Commit and push the changes in a new feature branch + git checkout -b $BRANCH_NAME + git add . + git commit -m "$COMMIT_MESSAGE" + git push origin $BRANCH_NAME + + # Store credentials for the Github CLI + echo "${{ secrets.GH_TOKEN }}" > access_token.txt + + # Authorize GitHub CLI for the current repository and + # create a pull-requests containing the updates. + gh auth login --with-token < access_token.txt + gh pr create \ + --body "" \ + --title "$COMMIT_MESSAGE" \ + --head "$BRANCH_NAME" \ + --base "main" diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 3f5d6e4..80f206a 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -8,6 +8,8 @@ on: - 'python/**' pull_request: types: [opened, synchronize, reopened] + paths: + - 'python/**' permissions: contents: read diff --git a/.github/workflows/ruby-ci.yml b/.github/workflows/ruby-ci.yml index aefe16a..b48bbc6 100644 --- a/.github/workflows/ruby-ci.yml +++ b/.github/workflows/ruby-ci.yml @@ -8,6 +8,8 @@ on: - 'ruby/**' pull_request: types: [opened, synchronize, reopened] + paths: + - 'ruby/**' permissions: contents: read diff --git a/php/generator/config.yaml b/php/generator/config.yaml new file mode 100644 index 0000000..db3e806 --- /dev/null +++ b/php/generator/config.yaml @@ -0,0 +1,14 @@ +globalProperties: + apiTests: true + modelTests: true + gitUserId: getlago + gitRepoId: lago-sdk/php + +additionalProperties: + packageName: lagoapi + packageUrl: https://github.com/getlago/sdk/php + packageVersion: API_VERSION + composerPackageName: getlago/sdk + developerOrganization: getlago + developerOrganizationUrl: https://www.getlago.com + licenseName: MIT