-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Skip stages when the commit is not important (Analysis,WaitApproval,Wait,ScriptRun) #4899
Comments
[Acknowledgment] |
I would like to add |
thanks, I agree with you and it's easily possible. |
cf. Skipping the |
The In our case, we plan to trigger an e2e testing by a script run stage. The stage should be skipped for quick rollback. |
I'll take this PR |
Configuration Example:
# Example for skipping stages with multiple events
name: skip-stage-example
on:
workflow_dispatch:
jobs:
publish-event:
name: Notify PipeCD
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
# Prepare a variable to judge
- name: "Count changed files"
run: echo "DIFF_COUNT=`git diff HEAD..HEAD~1 --name-only | wc -l`" >> $GITHUB_ENV
# Pattern-A
- name: "Register an event 'change-XS' to skip WAIT_APPROVAL and ANALYSIS stages"
uses: pipe-cd/actions-event-register@v1
if : env.DIFF_COUNT == 1
with:
api-address: ${{ secrets.PIPECD_API_ADDRESS }}
api-key: ${{ secrets.PIPECD_PLAN_PREVIEW_API_KEY }}
event-name: change-XS # important
labels: app=foo,env=dev
data: ${{ github.sha }} # Any data
pipectl-version: v0.47.2
# Pattern-B
- name: "Register an event 'change-S' to skip only ANALYSIS stage"
uses: pipe-cd/actions-event-register@v1
if : env.DIFF_COUNT == 2
with:
api-address: ${{ secrets.PIPECD_API_ADDRESS }}
api-key: ${{ secrets.PIPECD_PLAN_PREVIEW_API_KEY }}
event-name: change-S # important
labels: app=foo,env=dev
data: ${{ github.sha }} # Any data
pipectl-version: v0.47.2
apiVersion: pipecd.dev/v1beta1
kind: KubernetesApp
spec:
name: skip-stage-example
eventWatcher:
- matcher:
name: change-S # Any name
labels:
app: foo
env: dev
handler:
type: GIT_UPDATE
config:
commitMessage: "[change-s] update xxx" # Any message
replacements:
- file: deployment.yaml # Any file
yamlField: $.metadata.labels.gitsha # Any field
- matcher:
name: change-XS # Any name
labels:
app: foo
env: dev
handler:
type: GIT_UPDATE
config:
commitMessage: "[change-xs] update yyy" # Any message
replacements:
- file: deployment.yaml # Any file
yamlField: $.metadata.labels.gitsha # Any field
pipeline:
stages:
- name: K8S_CANARY_ROLLOUT
with:
replicas: 10%
- name: WAIT_APPROVAL
with:
skipOn:
commitMessagePrefixes:
- "[change-s]"
- "[change-xs]"
# ...
- name: ANALYSIS
with:
skipOn:
commitMessagePrefixes:
- "[change-xs]"
# ...
- name: K8S_PRIMARY_ROLLOUT
- name: K8S_CANARY_CLEAN |
Amazing magic! |
What would you like to be added
A new feature of skipping the
ANALYSIS
orWAIT_APPROVAL
stages when the commit diff is not important.The configurable conditions of skipping the stage:
Why is it needed
Some users would like to skip the
ANALYSIS
orWAIT_APPROVAL
stages for faster and automatic deployment when the commit diff does not deserve analysis or approval.use cases:
(a) When you modify only the
HorizontalPodAutoscaler
of K8s resources in your config repo, skip theWAIT_APPROVAL
stage.(b) When you modify only
go.mod
dependencies in your source repo(not pipecd's config repo), skip theANALYSIS
stage.(c) Skip the
WAIT_APPROVAL
stage when the change in your source repo is small, but skip both theWAIT_APPROVAL
andANALYSIS
stages when the change is tiny.How to realize it
skip
configuration to app.pipecd.yaml.Example1. How to realize the use case (b)
eventWatcher
andpipeline
in your app.pipecd.yaml.skip-analysis
if onlygo.mod
is changed.Example2. How to realize the use case (c)
eventWatcher
andpipeline
in your app.pipecd.yaml.small-change
to skip onlyWAIT_APPROVAL
, andtiny-change
to skip bothWAIT_APPROVAL
andANALYSIS
.Possible Extensions
commitMessagePrefixes
, it would be better to have other options like:skip.commitMessageOrBodyContains: []string
skip.commitMessageOrBodyContainsCommand: bool
[skip analysis]
,[skip stage]
, etc.The text was updated successfully, but these errors were encountered: