CI: add branches filter (#1130)

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
6543 2022-10-10 12:49:30 +02:00 committed by GitHub
parent 6789e28df2
commit f9dd6518c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 59 deletions

View file

@ -15,6 +15,14 @@ variables:
# web source code # web source code
- "web/**" - "web/**"
when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request # TODO: Do we need this :thinking:?
path: *when_path
pipeline: pipeline:
build-web: build-web:
group: prepare group: prepare
@ -24,63 +32,47 @@ pipeline:
- corepack enable - corepack enable
- pnpm install --frozen-lockfile - pnpm install --frozen-lockfile
- pnpm build - pnpm build
when:
path: *when_path
vendor: vendor:
group: prepare group: prepare
image: *golang_image image: *golang_image
commands: commands:
- go mod vendor - go mod vendor
when:
path: *when_path
build-server: build-server:
group: build group: build
image: *golang_image image: *golang_image
commands: commands:
- make release-server - make release-server
when:
path: *when_path
build-agent: build-agent:
group: build group: build
image: *golang_image image: *golang_image
commands: commands:
- make release-agent - make release-agent
when:
path: *when_path
build-cli: build-cli:
group: build group: build
image: *golang_image image: *golang_image
commands: commands:
- make release-cli - make release-cli
when:
path: *when_path
build-deb-rpm: build-deb-rpm:
group: bundle group: bundle
image: *golang_image image: *golang_image
commands: commands:
- make bundle - make bundle
when:
path: *when_path
build-tarball: build-tarball:
group: bundle group: bundle
image: *golang_image image: *golang_image
commands: commands:
- make release-tarball - make release-tarball
when:
path: *when_path
checksums: checksums:
image: *golang_image image: *golang_image
commands: commands:
- make release-checksums - make release-checksums
when:
path: *when_path
# TODO: upload build artifacts for pushes to ${CI_REPO_DEFAULT_BRANCH} # TODO: upload build artifacts for pushes to ${CI_REPO_DEFAULT_BRANCH}
@ -89,8 +81,6 @@ pipeline:
commands: commands:
- ls -la dist/*.* - ls -la dist/*.*
- cat dist/checksums.txt - cat dist/checksums.txt
when:
path: *when_path
release: release:
image: plugins/github-release image: plugins/github-release
@ -106,4 +96,3 @@ pipeline:
title: ${CI_COMMIT_TAG##v} title: ${CI_COMMIT_TAG##v}
when: when:
event: tag event: tag
# path conditions are ignored for tag events

View file

@ -12,6 +12,12 @@ variables:
- &platforms_preview 'linux/arm/v6,linux/arm64/v8,linux/amd64,linux/riscv64,windows/amd64' - &platforms_preview 'linux/arm/v6,linux/arm64/v8,linux/amd64,linux/riscv64,windows/amd64'
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le' - &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
- event: tag
- event: pull_request
pipeline: pipeline:
vendor: vendor:
image: *golang_image image: *golang_image

View file

@ -8,13 +8,19 @@ variables:
- "cli/**" - "cli/**"
- "cmd/cli/**" - "cmd/cli/**"
when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request
path: *when_path
pipeline: pipeline:
build-cli: build-cli:
image: *golang_image image: *golang_image
commands: commands:
- make docs - make docs
when:
path: *when_path
build: build:
image: *node_image image: *node_image
@ -23,8 +29,6 @@ pipeline:
- corepack enable - corepack enable
- pnpm install --frozen-lockfile - pnpm install --frozen-lockfile
- pnpm build - pnpm build
when:
path: *when_path
securitycheck: securitycheck:
image: aquasec/trivy:latest image: aquasec/trivy:latest
@ -32,8 +36,6 @@ pipeline:
- trivy fs --exit-code 0 --skip-dirs node_modules/ --skip-dirs plugins/woodpecker-plugins/node_modules --severity UNKNOWN,LOW docs/ - trivy fs --exit-code 0 --skip-dirs node_modules/ --skip-dirs plugins/woodpecker-plugins/node_modules --severity UNKNOWN,LOW docs/
# TODO currently it is not fixable so just do not block currently # TODO currently it is not fixable so just do not block currently
- trivy fs --exit-code 0 --skip-dirs node_modules/ --skip-dirs plugins/woodpecker-plugins/node_modules --severity MEDIUM,HIGH,CRITICAL docs/ - trivy fs --exit-code 0 --skip-dirs node_modules/ --skip-dirs plugins/woodpecker-plugins/node_modules --severity MEDIUM,HIGH,CRITICAL docs/
when:
path: *when_path
deploy-preview: deploy-preview:
image: woodpeckerci/plugin-surge-preview:next image: woodpeckerci/plugin-surge-preview:next
@ -47,7 +49,6 @@ pipeline:
from_secret: GITHUB_TOKEN_SURGE from_secret: GITHUB_TOKEN_SURGE
when: when:
event: pull_request event: pull_request
path: *when_path
# TODO: add step to remove preview again after PR is closed (waiting for #286) # TODO: add step to remove preview again after PR is closed (waiting for #286)
@ -75,4 +76,3 @@ pipeline:
when: when:
event: push event: push
branch: ${CI_REPO_DEFAULT_BRANCH} branch: ${CI_REPO_DEFAULT_BRANCH}
path: *when_path

View file

@ -1,3 +1,16 @@
variables:
- &when_path
- "charts/**"
- ".woodpecker/helm.yml"
when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request
path: *when_path
pipeline: pipeline:
set-version: set-version:
image: alpine/helm:3.5.3 image: alpine/helm:3.5.3
@ -10,22 +23,12 @@ pipeline:
- sed -i "s/<version>/$CHART_VERSION/g" charts/woodpecker-server/Chart.yaml - sed -i "s/<version>/$CHART_VERSION/g" charts/woodpecker-server/Chart.yaml
- cat charts/woodpecker-agent/Chart.yaml - cat charts/woodpecker-agent/Chart.yaml
- cat charts/woodpecker-server/Chart.yaml - cat charts/woodpecker-server/Chart.yaml
when:
path:
include:
- "charts/**"
- ".woodpecker/helm.yml"
lint: lint:
image: alpine/helm:3.5.3 image: alpine/helm:3.5.3
commands: commands:
- helm lint charts/woodpecker-agent/ - helm lint charts/woodpecker-agent/
- helm lint charts/woodpecker-server/ - helm lint charts/woodpecker-server/
when:
path:
include:
- "charts/**"
- ".woodpecker/helm.yml"
release: release:
image: quay.io/helmpack/chart-releaser:v1.4.0 image: quay.io/helmpack/chart-releaser:v1.4.0
@ -43,7 +46,3 @@ pipeline:
- cd woodpecker-ci.github.io/ && cr index --owner woodpecker-ci --git-repo woodpecker-ci.github.io --pages-branch master --package-path ../.cr-release-packages --index-path ../.cr-index/index.yaml --charts-repo https://woodpecker-ci.org --push --release-name-template "helm-{{ .Name }}-{{ .Version }}" - cd woodpecker-ci.github.io/ && cr index --owner woodpecker-ci --git-repo woodpecker-ci.github.io --pages-branch master --package-path ../.cr-release-packages --index-path ../.cr-index/index.yaml --charts-repo https://woodpecker-ci.org --push --release-name-template "helm-{{ .Name }}-{{ .Version }}"
when: when:
event: tag event: tag
path:
include:
- "charts/**"
- ".woodpecker/helm.yml"

View file

@ -11,6 +11,12 @@ variables:
# schema changes # schema changes
- "pipeline/schema/**" - "pipeline/schema/**"
when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
- event: tag
- event: pull_request
pipeline: pipeline:
vendor: vendor:
image: *golang_image image: *golang_image
@ -124,8 +130,6 @@ services:
environment: environment:
- POSTGRES_USER=postgres - POSTGRES_USER=postgres
- POSTGRES_HOST_AUTH_METHOD=trust - POSTGRES_HOST_AUTH_METHOD=trust
when:
path: *when_path
service-mysql: service-mysql:
image: mysql:5.6.27 image: mysql:5.6.27
@ -133,5 +137,3 @@ services:
environment: environment:
- MYSQL_DATABASE=test - MYSQL_DATABASE=test
- MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_ALLOW_EMPTY_PASSWORD=yes
when:
path: *when_path

View file

@ -6,6 +6,14 @@ variables:
# web source code # web source code
- "web/**" - "web/**"
when:
- event: push
branch: ["${CI_REPO_DEFAULT_BRANCH}", "release/*" ]
path: *when_path
- event: tag
- event: pull_request
path: *when_path
pipeline: pipeline:
deps: deps:
image: *node_image image: *node_image
@ -13,8 +21,6 @@ pipeline:
- cd web/ - cd web/
- corepack enable - corepack enable
- pnpm install --frozen-lockfile - pnpm install --frozen-lockfile
when:
path: *when_path
lint: lint:
group: test group: test
@ -23,8 +29,6 @@ pipeline:
- cd web/ - cd web/
- corepack enable - corepack enable
- pnpm lint - pnpm lint
when:
path: *when_path
formatcheck: formatcheck:
group: test group: test
@ -33,8 +37,6 @@ pipeline:
- cd web/ - cd web/
- corepack enable - corepack enable
- pnpm formatcheck - pnpm formatcheck
when:
path: *when_path
typecheck: typecheck:
group: test group: test
@ -43,8 +45,6 @@ pipeline:
- cd web/ - cd web/
- corepack enable - corepack enable
- pnpm typecheck - pnpm typecheck
when:
path: *when_path
securitycheck: securitycheck:
group: test group: test
@ -52,8 +52,6 @@ pipeline:
commands: commands:
- trivy fs --exit-code 0 --skip-dirs node_modules/ --severity UNKNOWN,LOW web/ - trivy fs --exit-code 0 --skip-dirs node_modules/ --severity UNKNOWN,LOW web/
- trivy fs --exit-code 1 --skip-dirs node_modules/ --severity MEDIUM,HIGH,CRITICAL web/ - trivy fs --exit-code 1 --skip-dirs node_modules/ --severity MEDIUM,HIGH,CRITICAL web/
when:
path: *when_path
test: test:
group: test group: test
@ -62,5 +60,3 @@ pipeline:
- cd web/ - cd web/
- corepack enable - corepack enable
- pnpm test - pnpm test
when:
path: *when_path

View file

@ -15,14 +15,15 @@
"description": "Use yaml aliases to define variables. Read more: https://woodpecker-ci.org/docs/usage/advanced-yaml-syntax" "description": "Use yaml aliases to define variables. Read more: https://woodpecker-ci.org/docs/usage/advanced-yaml-syntax"
}, },
"clone": { "$ref": "#/definitions/clone" }, "clone": { "$ref": "#/definitions/clone" },
"skip_clone": { "type": "boolean" },
"branches": { "$ref": "#/definitions/branches" }, "branches": { "$ref": "#/definitions/branches" },
"when": { "$ref": "#/definitions/pipeline_when" },
"pipeline": { "$ref": "#/definitions/pipeline" }, "pipeline": { "$ref": "#/definitions/pipeline" },
"services": { "$ref": "#/definitions/services" }, "services": { "$ref": "#/definitions/services" },
"workspace": { "$ref": "#/definitions/workspace" }, "workspace": { "$ref": "#/definitions/workspace" },
"matrix": { "$ref": "#/definitions/matrix" }, "matrix": { "$ref": "#/definitions/matrix" },
"platform": { "$ref": "#/definitions/platform" }, "platform": { "$ref": "#/definitions/platform" },
"labels": { "$ref": "#/definitions/labels" }, "labels": { "$ref": "#/definitions/labels" },
"skip_clone": { "type": "boolean" },
"depends_on": { "depends_on": {
"type": "array", "type": "array",
"minLength": 1, "minLength": 1,
@ -99,7 +100,7 @@
] ]
}, },
"pipeline_when": { "pipeline_when": {
"description": "Whole pipelines can be skipped based on conditions. Read more: TODO", "description": "Whole pipelines can be skipped based on conditions. Read more: https://woodpecker-ci.org/docs/next/usage/pipeline-syntax#when---global-pipeline-conditions",
"oneOf": [ "oneOf": [
{ {
"type": "array", "type": "array",