From dcfca1bba4736ec12289c58f9aa3a720ea9043bb Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Wed, 11 Sep 2024 13:44:08 +0100 Subject: [PATCH] internal/ci: add workflowDispatch step template This resurrects the workflowDispatch step template that was previously removed in https://cuelang.org/cl/1196926, so that it can be used by a follow-up. Signed-off-by: Jonathan Matthews Change-Id: I3ebe09cc0a8b594e33faeb5ad8bad6f0022c2a8e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201006 Reviewed-by: Paul Jolly TryBot-Result: CUEcueckoo --- internal/ci/base/github.cue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/ci/base/github.cue b/internal/ci/base/github.cue index 6f49044bd0e..fbbf499c4a8 100644 --- a/internal/ci/base/github.cue +++ b/internal/ci/base/github.cue @@ -289,6 +289,24 @@ repositoryDispatch: json.#step & { """# } +workflowDispatch: json.#step & { + #githubRepositoryPath: *githubRepositoryPath | string + #botGitHubUserTokenSecretsKey: *botGitHubUserTokenSecretsKey | string + #workflowID: string + + // params are defined per https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event + #params: *{ + ref: defaultBranch + } | _ + + _curlGitHubAPI: curlGitHubAPI & {#tokenSecretsKey: #botGitHubUserTokenSecretsKey, _} + + name: string + run: #""" + \#(_curlGitHubAPI) --fail --request POST --data-binary \#(strconv.Quote(encjson.Marshal(#params))) https://api.github.com/repos/\#(#githubRepositoryPath)/actions/workflows/\#(#workflowID)/dispatches + """# +} + // dispatchTrailer is the trailer that we use to pass information in a commit // when triggering workflow events in other GitHub repos. //