Support github deploy task (#3512)

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
Fernando Barbosa
2024-05-02 13:56:19 -03:00
committed by GitHub
parent 225ddb586d
commit e6bda2c2b3
15 changed files with 44 additions and 16 deletions

View File

@@ -48,6 +48,7 @@
"deploy_pipeline": {
"title": "Trigger deployment event for current pipeline #{pipelineId}",
"enter_target": "Target deployment environment",
"enter_task": "Deployment task",
"trigger": "Deploy",
"variables": {
"delete": "Delete variable",

View File

@@ -8,6 +8,9 @@
<InputField v-slot="{ id }" :label="$t('repo.deploy_pipeline.enter_target')">
<TextField :id="id" v-model="payload.environment" required />
</InputField>
<InputField v-slot="{ id }" :label="$t('repo.deploy_pipeline.enter_task')">
<TextField :id="id" v-model="payload.task" />
</InputField>
<InputField v-slot="{ id }" :label="$t('repo.deploy_pipeline.variables.title')">
<span class="text-sm text-wp-text-alt-100 mb-2">{{ $t('repo.deploy_pipeline.variables.desc') }}</span>
<div class="flex flex-col gap-2">
@@ -69,9 +72,10 @@ const repo = inject('repo');
const router = useRouter();
const payload = ref<{ id: string; environment: string; variables: { name: string; value: string }[] }>({
const payload = ref<{ id: string; environment: string; task: string; variables: { name: string; value: string }[] }>({
id: '',
environment: '',
task: '',
variables: [
{
name: '',

View File

@@ -31,6 +31,7 @@ type PipelineOptions = {
type DeploymentOptions = {
id: string;
environment: string;
task: string;
variables: Record<string, string>;
};
@@ -89,12 +90,13 @@ export default class WoodpeckerClient extends ApiClient {
}
// Deploy triggers a deployment for an existing pipeline using the
// specified target environment.
// specified target environment and task.
deployPipeline(repoId: number, pipelineNumber: string, options: DeploymentOptions): Promise<Pipeline> {
const vars = {
...options.variables,
event: 'deployment',
deploy_to: options.environment,
deploy_task: options.task,
};
const query = encodeQueryString(vars);
return this._post(`/api/repos/${repoId}/pipelines/${pipelineNumber}?${query}`) as Promise<Pipeline>;