I’ve got a CCI job that looks something like this:
- docker-build-job:
# ... only build container if on `main` or relevant files changed
# ... tag with branch-name
- job-a:
executor:
# ... uses `main` executor
requires:
- docker-build-job
- job-b:
executor:
# ... uses `main` executor
requires:
- docker-build-job
This current state is a result of a few things we tried:
- We tried to use a branch filter on
docker-build-job
, but that meant that downstream jobs (job-a
,job-b
) never run whendocker-build-job
runs. - To solve that, we add a step to
docker-build-job
that checks branch and file changes to make sure we only build when needed.
Unfortunately, in order to determine if we should/should not skip, we have to spin up the docker environment, which takes ~1 min at least.
What we’d like is:
- in
main
, always build the docker image and use it to runjob-a
,job-b
- in branches, if certain files change, build the docker image for the branch and use it to run
job-a
,job-b
(*) - in branches, when no relevant files changed, only run
job-a
,job-b
using themain
container (the most common)
Here are the priorities as of now:
- MOST IMPORTANT: 0 time spent spinning up the docker-env in the most common case - the last bullet above.
- SECONDARY: use an executor with the current branch only if the relevant files changed on this branch.
Any ideas how I could achieve this?