You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-07-12 22:21:40 +02:00
Only allow to deploy from push, tag and release (#3522)
This commit is contained in:
@ -409,12 +409,19 @@ func PostPipeline(c *gin.Context) {
|
||||
// make Deploy overridable
|
||||
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 {
|
||||
// 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)
|
||||
|
||||
if err := pl.Event.Validate(); err != nil {
|
||||
_ = c.AbortWithError(http.StatusBadRequest, err)
|
||||
if pl.Event != model.EventDeploy {
|
||||
_ = c.AbortWithError(http.StatusBadRequest, model.ErrInvalidWebhookEvent)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user