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

Add replace-all option #2

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Your [Svix API key](https://docs.svix.com/api-keys).
**Optional**
Override the Svix API URL. If not set, the URL will be determined using the API Key.

### `replace-all`
**Optional**
If true, archives all existing event types that are not in the OpenAPI spec. Default: `false`.

## Usage

To use this GitHub Action in your workflow, you can add the following step:
Expand Down
18 changes: 11 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: 'Upload Event Types to Svix'
description: 'Upload Event Types from an OpenAPI spec to Svix'
name: "Upload Event Types to Svix"
description: "Upload Event Types from an OpenAPI spec to Svix"
inputs:
openapi-file:
description: 'Location of the OpenAPI spec file (JSON or YAML)'
description: "Location of the OpenAPI spec file (JSON or YAML)"
required: true
svix-api-key:
description: 'Svix API key'
description: "Svix API key"
required: true
svix-api-url:
description: 'Override Svix API URL'
description: "Override Svix API URL"
required: false
replace-all:
description: "Archive all existing event types that are not in the OpenAPI spec"
required: false
default: "false"
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -44,7 +48,7 @@ runs:
- name: Upload OpenAPI spec to Svix
run: |
TMP_PAYLOAD=$(mktemp)
python3 -c "import json; print(json.dumps({'specRaw': open('./${{inputs.openapi-file}}','r').read()}))" > $TMP_PAYLOAD
python3 -c "import json; print(json.dumps({'specRaw': open('./${{inputs.openapi-file}}','r').read(), 'replaceAll': "${{inputs.replace-all == 'true' || inputs.replace-all == true}}" == "true" }))" > $TMP_PAYLOAD
svix-lucho marked this conversation as resolved.
Show resolved Hide resolved

echo "Uploading OpenAPI spec to https://$SVIX_API_URL/api/v1/event-type/import/openapi/"

Expand All @@ -55,4 +59,4 @@ runs:
--data-binary "@$TMP_PAYLOAD" | jq

rm $TMP_PAYLOAD
shell: bash
shell: bash