This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from getlago/add-php
misc(php): Add PHP SDK
- Loading branch information
Showing
5 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
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
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
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" |
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
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
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
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 |