Skip to content

Commit

Permalink
SWI-6181 Update Action (#40)
Browse files Browse the repository at this point in the history
* SWI-6181 Update Action

* add additional-properties input

* update readme
  • Loading branch information
ckoegel authored Nov 8, 2024
1 parent deffd1d commit 4814af0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 88 deletions.
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 }}

0 comments on commit 4814af0

Please sign in to comment.