From 6ed1655ce3770b010c3b5204cadee49dc246f498 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Wed, 31 Jan 2024 16:18:32 +0100 Subject: [PATCH] Add release types (#3303) Co-authored-by: pat-s --- docs/docs/20-usage/15-terminiology/index.md | 2 +- docs/docs/20-usage/20-workflow-syntax.md | 6 +++++- server/api/queue.go | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 server/api/queue.go diff --git a/docs/docs/20-usage/15-terminiology/index.md b/docs/docs/20-usage/15-terminiology/index.md index 4e58b9630..4e4f61489 100644 --- a/docs/docs/20-usage/15-terminiology/index.md +++ b/docs/docs/20-usage/15-terminiology/index.md @@ -38,7 +38,7 @@ - `pull_request`: A pull request event is triggered when a pull request is opened or a new commit is pushed to it. - `pull_request_closed`: A pull request closed event is triggered when a pull request is closed or merged. - `tag`: A tag event is triggered when a tag is pushed. -- `release`: A release event is triggered when a release is created. +- `release`: A release event is triggered when a release, pre-release or draft is created. (You can apply further filters using [evaluate](../20-workflow-syntax.md#evaluate) with [environment variables](../50-environment.md#built-in-environment-variables).) - `manual`: A manual event is triggered when a user manually triggers a pipeline. - `cron`: A cron event is triggered when a cron job is executed. diff --git a/docs/docs/20-usage/20-workflow-syntax.md b/docs/docs/20-usage/20-workflow-syntax.md index a21360a81..1f9d80248 100644 --- a/docs/docs/20-usage/20-workflow-syntax.md +++ b/docs/docs/20-usage/20-workflow-syntax.md @@ -757,6 +757,10 @@ when: ### `event` +:::warning +Some events like the release event will be triggered for multiple actions like: releases, pre-releases and drafts. If you want to apply further filters checkout the [evaluate](#evaluate) filter and the available [environment variables](./50-environment.md#built-in-environment-variables). +::: + Execute a step if the build event is a `tag`: ```yaml @@ -783,7 +787,7 @@ Execute a step for all build events: ```yaml when: - event: [push, pull_request, tag, deployment] + event: [push, pull_request, pull_request_closed, tag, deployment, release] ``` ### `ref` diff --git a/server/api/queue.go b/server/api/queue.go new file mode 100644 index 000000000..74d5f332d --- /dev/null +++ b/server/api/queue.go @@ -0,0 +1,21 @@ +package api + +import ( + "encoding/json" + "log" + "net/http" + + "go.woodpecker-ci.org/woodpecker/v2/server/queue" // replace with the actual import path +) + +func GetQueueStats() { + http.HandleFunc("/api/queue/stats", func(w http.ResponseWriter, r *http.Request) { + var stats queue.InfoT + err := json.NewEncoder(w).Encode(stats) + if err != nil { + // handle the error + log.Printf("Error encoding JSON: %v", err) + return + } + }) +}