hi I have 1 gitea repository with 5 different docker-compose.yaml files. if 1 changes (lets say nextcloud.yaml) I want DroneCI to only update that one docker image (the nextcloud image) , not the other ones.
how do i get this done?
Do i need a drone.yml for every service or do i need multiple repositories or is there a way droneci can handle this in just one drone.yml?
drone does not natively solve for this scenario, however, folks have created extensions that augment drone’s behavior to handle these scenarios. see http://discuss.harness.io/t/condition-on-changes-to-paths/8755/2
it seems that both suggested extensions don’t work with gitea only github for example or bitbucket. Unfortunately. Could I somehow solve this without an extension?
If the current extensions does not work with Gitea you would have the option to contribute, fork, or create a custom extension. We provide a quick start template to create your own extensions [1].
If you do not want to create a custom extension, you could always use shell scripting to achieve your goals. It may be possible, for example, to use the commit before [2] and commit after [3] variables to generate a diff and exit. You could take it a step further and wrap this login as a plugin [4].
This is pseudo code to demonstrate, based on this example:
steps:
- name: build
image: docker
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- git diff --exit-code path/to/source/dir || exit 0
- docker login --username <username> --password <password>
- docker build -t <image> .
- docker push <image>
volumes:
- name: docker
host:
path: /var/run/docker.sock
These are really the only two options I can think of. Drone does not have native support for limiting steps or stages based on files changed, which means your only option is to use an extension or use shell scripting.
[1] https://docs.drone.io/extensions/conversion/#starter-project
[2] https://docs.drone.io/pipeline/environment/reference/drone-commit-before/
[3] https://docs.drone.io/pipeline/environment/reference/drone-commit-after/
[4] https://docs.drone.io/plugins/overview/