mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 00:11:04 +00:00 
			
		
		
		
	Closes #2797 I'm aware of https://github.com/go-gitea/gitea/pull/28163 exists, but since I had it laying around on my drive and collecting dust, I might as well open a PR for it if anyone wants the feature a bit sooner than waiting for upstream to release it or to be a forgejo "native" implementation. This PR Contains: - Support for the `workflow_dispatch` trigger - Inputs: boolean, string, number, choice Things still to be done: - [x] API Endpoint `/api/v1/<org>/<repo>/actions/workflows/<workflow id>/dispatches` - ~~Fixing some UI bugs I had no time figuring out, like why dropdown/choice inputs's menu's behave weirdly~~ Unrelated visual bug with dropdowns inside dropdowns - [x] Fix bug where opening the branch selection submits the form - [x] Limit on inputs to render/process Things not in this PR: - Inputs: environment (First need support for environments in forgejo) Things needed to test this: - A patch for https://code.forgejo.org/forgejo/runner to actually consider the inputs inside the workflow. ~~One possible patch can be seen here: https://code.forgejo.org/Mai-Lapyst/runner/src/branch/support-workflow-inputs~~ [PR](https://code.forgejo.org/forgejo/runner/pulls/199)  ## Testing - Checkout PR - Setup new development runner with [this PR](https://code.forgejo.org/forgejo/runner/pulls/199) - Create a repo with a workflow (see below) - Go to the actions tab, select the workflow and see the notice as in the screenshot above - Use the button + dropdown to run the workflow - Try also running it via the api using the `` endpoint - ... - Profit! <details> <summary>Example workflow</summary> ```yaml on: workflow_dispatch: inputs: logLevel: description: 'Log Level' required: true default: 'warning' type: choice options: - info - warning - debug tags: description: 'Test scenario tags' required: false type: boolean boolean_default_true: description: 'Test scenario tags' required: true type: boolean default: true boolean_default_false: description: 'Test scenario tags' required: false type: boolean default: false number1_default: description: 'Number w. default' default: '100' type: number number2: description: 'Number w/o. default' type: number string1_default: description: 'String w. default' default: 'Hello world' type: string string2: description: 'String w/o. default' required: true type: string jobs: test: runs-on: docker steps: - uses: actions/checkout@v3 - run: whoami - run: cat /etc/issue - run: uname -a - run: date - run: echo ${{ inputs.logLevel }} - run: echo ${{ inputs.tags }} - env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - run: echo "abc" ``` </details> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3334 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org> Co-committed-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
		
			
				
	
	
		
			222 lines
		
	
	
	
		
			4.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			222 lines
		
	
	
	
		
			4.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2024 The Forgejo Authors. All rights reserved.
 | 
						|
// Copyright 2017 The Gitea Authors. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package swagger
 | 
						|
 | 
						|
import (
 | 
						|
	ffed "code.gitea.io/gitea/modules/forgefed"
 | 
						|
	api "code.gitea.io/gitea/modules/structs"
 | 
						|
	"code.gitea.io/gitea/services/forms"
 | 
						|
)
 | 
						|
 | 
						|
// not actually a response, just a hack to get go-swagger to include definitions
 | 
						|
// of the various XYZOption structs
 | 
						|
 | 
						|
// parameterBodies
 | 
						|
// swagger:response parameterBodies
 | 
						|
type swaggerParameterBodies struct {
 | 
						|
	// in:body
 | 
						|
	ForgeLike ffed.ForgeLike
 | 
						|
 | 
						|
	// in:body
 | 
						|
	AddCollaboratorOption api.AddCollaboratorOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	ReplaceFlagsOption api.ReplaceFlagsOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateEmailOption api.CreateEmailOption
 | 
						|
	// in:body
 | 
						|
	DeleteEmailOption api.DeleteEmailOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateHookOption api.CreateHookOption
 | 
						|
	// in:body
 | 
						|
	EditHookOption api.EditHookOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	EditGitHookOption api.EditGitHookOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateIssueOption api.CreateIssueOption
 | 
						|
	// in:body
 | 
						|
	EditIssueOption api.EditIssueOption
 | 
						|
	// in:body
 | 
						|
	EditDeadlineOption api.EditDeadlineOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateIssueCommentOption api.CreateIssueCommentOption
 | 
						|
	// in:body
 | 
						|
	EditIssueCommentOption api.EditIssueCommentOption
 | 
						|
	// in:body
 | 
						|
	IssueMeta api.IssueMeta
 | 
						|
 | 
						|
	// in:body
 | 
						|
	IssueLabelsOption api.IssueLabelsOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	DeleteLabelsOption api.DeleteLabelsOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateKeyOption api.CreateKeyOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	RenameUserOption api.RenameUserOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateLabelOption api.CreateLabelOption
 | 
						|
	// in:body
 | 
						|
	EditLabelOption api.EditLabelOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	MarkupOption api.MarkupOption
 | 
						|
	// in:body
 | 
						|
	MarkdownOption api.MarkdownOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateMilestoneOption api.CreateMilestoneOption
 | 
						|
	// in:body
 | 
						|
	EditMilestoneOption api.EditMilestoneOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateOrgOption api.CreateOrgOption
 | 
						|
	// in:body
 | 
						|
	EditOrgOption api.EditOrgOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreatePullRequestOption api.CreatePullRequestOption
 | 
						|
	// in:body
 | 
						|
	EditPullRequestOption api.EditPullRequestOption
 | 
						|
	// in:body
 | 
						|
	MergePullRequestOption forms.MergePullRequestForm
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateReleaseOption api.CreateReleaseOption
 | 
						|
	// in:body
 | 
						|
	EditReleaseOption api.EditReleaseOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateRepoOption api.CreateRepoOption
 | 
						|
	// in:body
 | 
						|
	EditRepoOption api.EditRepoOption
 | 
						|
	// in:body
 | 
						|
	TransferRepoOption api.TransferRepoOption
 | 
						|
	// in:body
 | 
						|
	CreateForkOption api.CreateForkOption
 | 
						|
	// in:body
 | 
						|
	GenerateRepoOption api.GenerateRepoOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateStatusOption api.CreateStatusOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateTeamOption api.CreateTeamOption
 | 
						|
	// in:body
 | 
						|
	EditTeamOption api.EditTeamOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	AddTimeOption api.AddTimeOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateUserOption api.CreateUserOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	EditUserOption api.EditUserOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	EditAttachmentOptions api.EditAttachmentOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	ChangeFilesOptions api.ChangeFilesOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateFileOptions api.CreateFileOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	UpdateFileOptions api.UpdateFileOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	DeleteFileOptions api.DeleteFileOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CommitDateOptions api.CommitDateOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	RepoTopicOptions api.RepoTopicOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	EditReactionOption api.EditReactionOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateBranchRepoOption api.CreateBranchRepoOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateBranchProtectionOption api.CreateBranchProtectionOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	EditBranchProtectionOption api.EditBranchProtectionOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateOAuth2ApplicationOptions api.CreateOAuth2ApplicationOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreatePullReviewOptions api.CreatePullReviewOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreatePullReviewComment api.CreatePullReviewComment
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreatePullReviewCommentOptions api.CreatePullReviewCommentOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	SubmitPullReviewOptions api.SubmitPullReviewOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	DismissPullReviewOptions api.DismissPullReviewOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	MigrateRepoOptions api.MigrateRepoOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	PullReviewRequestOptions api.PullReviewRequestOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateTagOption api.CreateTagOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateTagProtectionOption api.CreateTagProtectionOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	EditTagProtectionOption api.EditTagProtectionOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateAccessTokenOption api.CreateAccessTokenOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	UserSettingsOptions api.UserSettingsOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateWikiPageOptions api.CreateWikiPageOptions
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreatePushMirrorOption api.CreatePushMirrorOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	UpdateUserAvatarOptions api.UpdateUserAvatarOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	UpdateRepoAvatarOptions api.UpdateRepoAvatarOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateOrUpdateSecretOption api.CreateOrUpdateSecretOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	CreateVariableOption api.CreateVariableOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	UpdateVariableOption api.UpdateVariableOption
 | 
						|
 | 
						|
	// in:body
 | 
						|
	DispatchWorkflowOption api.DispatchWorkflowOption
 | 
						|
}
 |