Merge branch 'ci_rules' into 'main'

Rework pipeline triggers for MRs

See merge request nvidia/container-toolkit/container-toolkit!346
This commit is contained in:
Carlos Eduardo Arango Gutierrez 2023-03-15 13:15:23 +00:00
commit 7000c6074e
2 changed files with 28 additions and 10 deletions

View File

@ -23,6 +23,7 @@ variables:
BUILD_MULTI_ARCH_IMAGES: "true"
stages:
- trigger
- image
- lint
- go-checks
@ -34,22 +35,44 @@ stages:
- scan
- release
workflow:
.pipeline-trigger-rules:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# We trigger the pipeline if started manually
- if: $CI_PIPELINE_SOURCE == "web"
# We trigger the pipeline on the main branch
- if: $CI_COMMIT_BRANCH == "main"
# We trigger the pipeline on the release- branches
- if: $CI_COMMIT_BRANCH =~ /^release-.*$/
# We trigger the pipeline on tags
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG != ""
workflow:
rules:
# We trigger the pipeline on a merge request
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# We then add all the regular triggers
- !reference [.pipeline-trigger-rules, rules]
# The main or manual job is used to filter out distributions or architectures that are not required on
# every build.
.main-or-manual:
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH =~ /^release-.*$/
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG != ""
- !reference [.pipeline-trigger-rules, rules]
- if: $CI_PIPELINE_SOURCE == "schedule"
when: manual
# The trigger-pipeline job adds a manualy triggered job to the pipeline on merge requests.
trigger-pipeline:
stage: trigger
script:
- echo "starting pipeline"
rules:
- !reference [.main-or-manual, rules]
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: false
- when: always
# Define the distribution targets
.dist-amazonlinux2:
rules:

View File

@ -22,11 +22,6 @@ build-dev-image:
- make .build-image
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- make .push-build-image
rules:
- !reference [.main-or-manual, rules]
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
- when: always
.requires-build-image:
image: "${BUILDIMAGE}"