mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
Only allow to deploy from push, tag and release (#3522)
This commit is contained in:
parent
00b1651f47
commit
e00b2d4bd3
2 changed files with 14 additions and 4 deletions
|
@ -409,12 +409,19 @@ func PostPipeline(c *gin.Context) {
|
||||||
// make Deploy overridable
|
// make Deploy overridable
|
||||||
pl.Deploy = c.DefaultQuery("deploy_to", pl.Deploy)
|
pl.Deploy = c.DefaultQuery("deploy_to", pl.Deploy)
|
||||||
|
|
||||||
// make Event overridable
|
// make Event overridable to deploy
|
||||||
|
// TODO refactor to use own proper API for deploy
|
||||||
if event, ok := c.GetQuery("event"); ok {
|
if event, ok := c.GetQuery("event"); ok {
|
||||||
|
// only allow deploy from push, tag and release
|
||||||
|
if pl.Event != model.EventPush && pl.Event != model.EventTag && pl.Event != model.EventRelease {
|
||||||
|
_ = c.AbortWithError(http.StatusBadRequest, fmt.Errorf("can only deploy push, tag and release pipelines"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
pl.Event = model.WebhookEvent(event)
|
pl.Event = model.WebhookEvent(event)
|
||||||
|
|
||||||
if err := pl.Event.Validate(); err != nil {
|
if pl.Event != model.EventDeploy {
|
||||||
_ = c.AbortWithError(http.StatusBadRequest, err)
|
_ = c.AbortWithError(http.StatusBadRequest, model.ErrInvalidWebhookEvent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,10 @@
|
||||||
@click="restartPipeline"
|
@click="restartPipeline"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
v-if="pipeline.status === 'success'"
|
v-if="
|
||||||
|
pipeline.status === 'success' &&
|
||||||
|
(pipeline.event === 'push' || pipeline.event === 'tag' || pipeline.event === 'release')
|
||||||
|
"
|
||||||
class="flex-shrink-0"
|
class="flex-shrink-0"
|
||||||
:text="$t('repo.pipeline.actions.deploy')"
|
:text="$t('repo.pipeline.actions.deploy')"
|
||||||
@click="showDeployPipelinePopup = true"
|
@click="showDeployPipelinePopup = true"
|
||||||
|
|
Loading…
Reference in a new issue