Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

misc(php): Add PHP SDK #6

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- 'go/**'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'go/**'

permissions:
contents: read
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/php-generate.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- 'python/**'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'python/**'

permissions:
contents: read
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ruby-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- 'ruby/**'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'ruby/**'

permissions:
contents: read
Expand Down
14 changes: 14 additions & 0 deletions php/generator/config.yaml
Original file line number Diff line number Diff line change
@@ -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