From bd37d99e6a3ec17d1233d2f10040a8cf39d89943 Mon Sep 17 00:00:00 2001 From: Ryan Albert <42415738+ryan-timothy-albert@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:48:17 -0700 Subject: [PATCH] feat: provide target in run workflow (#109) * feat: provide target in run workflow * feat: provide target in run workflow --- .github/workflows/workflow-executor.yaml | 5 +++++ action.yml | 4 ++++ internal/cli/cli.go | 7 ++++++- internal/environment/environment.go | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow-executor.yaml b/.github/workflows/workflow-executor.yaml index 0f21158b..d38c1a00 100644 --- a/.github/workflows/workflow-executor.yaml +++ b/.github/workflows/workflow-executor.yaml @@ -19,6 +19,10 @@ on: default: "direct" required: false type: string + target: + description: "Generate a specific target by name" + required: false + type: string force: description: "Force the generation of the SDKs" default: "false" @@ -134,6 +138,7 @@ jobs: speakeasy_server_url: ${{ inputs.speakeasy_server_url }} working_directory: ${{ inputs.working_directory }} openapi_doc_auth_token: ${{ secrets.openapi_doc_auth_token }} + target: ${{ inputs.target }} - uses: ravsamhq/notify-slack-action@v2 if: always() && env.SLACK_WEBHOOK_URL != '' with: diff --git a/action.yml b/action.yml index 4f687d0e..6cb8554b 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,9 @@ inputs: description: "Force the SDK to be regenerated" default: "false" required: false + target: + description: "Generate a specific target by name" + required: false max_suggestions: description: "The maximum number of suggestions to apply when using the 'suggest' action step." default: "5" @@ -157,3 +160,4 @@ runs: - ${{ inputs.working_directory }} - ${{ inputs.gpg_fingerprint }} - ${{ inputs.openapi_doc_auth_token }} + - ${{ inputs.target }} diff --git a/internal/cli/cli.go b/internal/cli/cli.go index e1a455fc..495e8be9 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -48,7 +48,12 @@ func Run(sourcesOnly bool, installationURLs map[string]string, repoURL string, r if sourcesOnly { args = append(args, "-s", "all") } else { - args = append(args, "-t", "all") + specifiedTarget := environment.SpecifiedTarget() + if specifiedTarget != "" { + args = append(args, "-t", specifiedTarget) + } else { + args = append(args, "-t", "all") + } urls, err := json.Marshal(installationURLs) if err != nil { return fmt.Errorf("error marshalling installation urls: %w", err) diff --git a/internal/environment/environment.go b/internal/environment/environment.go index a1681459..c1240cda 100644 --- a/internal/environment/environment.go +++ b/internal/environment/environment.go @@ -56,6 +56,10 @@ func ForceGeneration() bool { return os.Getenv("INPUT_FORCE") == "true" } +func SpecifiedTarget() string { + return os.Getenv("INPUT_TARGET") +} + func GetMode() Mode { mode := os.Getenv("INPUT_MODE") if mode == "" {