Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWI-6181 Update Action #40

Merged
merged 3 commits into from
Nov 8, 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
17 changes: 0 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,13 @@ jobs:
test:
name: Test
runs-on: ${{ fromJSON(vars.SWI_GLORG_UBUNTU_2204) }}
permissions:
id-token: write
contents: write
steps:
- name: Get Github Token from Vault
uses: Bandwidth/vault-provider-action@v1
with:
export-github-pat: true

- name: Checkout
uses: actions/checkout@v4

- name: Run Test with Local Files
id: generate
uses: ./
with:
branch-name: ci-cd-test
token: ${{ env.GITHUB_TEAM_ACCESS_TOKEN }}
openapi-generator-version: 6.5.0
language: python
api-spec-path: ./utils/bandwidth.yml
config: ./utils/test-config.yml

- name: Delete Branch
if: ${{ always() }}
run: git push origin --delete ci-cd-test
shell: bash
34 changes: 9 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,27 @@ This action utilizes the [openapi-generator-cli](https://github.com/OpenAPITools
## Inputs

```yml
branch-name:
description: Branch name
required: true
token:
description: Github auth token
required: true
language:
description: The generator name (language) (`-g`) argument for the openapi-generator-cli
required: true
config:
description: The configuration (`-c`) argument for the openapi-generator-cli
required: true
user-email:
description: Git user email
default: [email protected]
required: false
username:
description: Github username
default: DX-Bandwidth
default: ./openapi-config.yml
api-spec-path:
description: The destination of the API Specification to generate a client from
required: false
default: ./bandwidth.yml
openapi-generator-version:
description: The OpenAPI Generator project version, in `x.x.x` format
required: false
default: '6.5.0'
api-spec-path:
description: The destination of the API Specification to generate a client from
default: '7.6.0'
additional-properties:
description: Additional properties to pass to the generator
required: false
default: ./bandwidth.yml
working-directory:
default: ''
working-directory:
description: The working directory to run the action in
required: false
default: ./
```

## Outputs

```yml
changes:
description: Boolean representing if files in the SDK were changed or not.
```
55 changes: 9 additions & 46 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,30 @@
name: Generate SDK Action
description: Generate an SDK using the OpenAPI Generator Project
inputs:
branch-name:
description: Branch name
required: true
token:
description: Github auth token
required: true
language:
description: The generator name (language) (`-g`) argument for the openapi-generator-cli
required: true
config:
description: The configuration (`-c`) argument for the openapi-generator-cli
required: true
user-email:
description: Git user email
default: [email protected]
required: false
username:
description: Github username
default: DX-Bandwidth
default: ./openapi-config.yml
api-spec-path:
description: The destination of the API Specification to generate a client from
required: false
default: ./bandwidth.yml
openapi-generator-version:
description: The OpenAPI Generator project version, in `x.x.x` format
required: false
default: '6.5.0'
api-spec-path:
description: The destination of the API Specification to generate a client from
default: '7.6.0'
additional-properties:
description: Additional properties to pass to the generator
required: false
default: ./bandwidth.yml
default: ''
working-directory:
description: The working directory to run the action in
required: false
default: ./

outputs:
changes:
description: Boolean representing if files in the SDK were changed or not.
value: ${{ steps.commit.outputs.changes }}

runs:
using: composite
steps:
Expand All @@ -47,14 +33,6 @@ runs:
with:
node-version: 20

- name: Configure Git and Create Branch
run: |
git config user.email ${{ inputs.user-email }}
git config user.name ${{ inputs.username }}
git checkout -b ${{ inputs.branch-name }}
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Setup OpenAPI Generator CLI
run: |
npm install @openapitools/openapi-generator-cli -g
Expand All @@ -68,22 +46,7 @@ runs:
-g ${{ inputs.language }} \
-i ${{ inputs.api-spec-path }} \
-c ${{ inputs.config }} \
${{ inputs.additional-properties }} \
-o ./
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Commit if Necessary
id: commit
run: |
if git diff --quiet; then
echo "No Changes"
else
git add .
git commit -m "Generate SDK with OpenAPI Generator Version ${{ inputs.openapi-generator-version }}"
git push origin ${{ inputs.branch-name }}
echo "changes=true" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ inputs.token }}
shell: bash
working-directory: ${{ inputs.working-directory }}