How to run a pipeline step only when pushing to a new branch?
GitHub sends push hook when pushing to a new branch and merging a PR. How can we distinguish between them?
We are running integration test by triggering a downstream build when a PR is merged into specific branches. In the downstream repository, we pull all the docker images which has been built and pushed from upstream. The thing is we also used the drone-convert-pathschanged to only publish what modules has been changed.
So, what happens when pushing to a new
No code changed -> publish steps won’t run -> the docker images does not exist -> integration test failed.
How can we solve this situation?
GitHub created two hooks when pushing to a new branch:
- X-GitHub-Event: create
- X-GitHub-Event: push
Since Drone ignores the “create” event, how can we know that a branch has been created in a “push” event? By looking at the Webhook payloads docs, we can check if “Created” is true or false. Turn out that there is another way to check.
A condition for a step to run when pushing to a new branch will be something like this:
1 when: 2 action: 3 - create 4 branch: 5 - release-* 6 event: 7 - push
It can be distinguished with the step is run when a PR is merged into
1 when: 2 action: 3 exclude: 4 - create 5 branch: 6 - release-* 7 event: 8 - push
Tags: drone ci monorepo integration-test golang
- plugins/docker failed to resolve Keycloak hostname?
- How to perform integration testing in Go?
- How to trigger build steps based on modified directory?
- Drone build is not triggered after pushing code to Gitea?
- How to create snippets in Helix?