I’m trying to publish Docker images built from the master branch to a production repository and all other dev branches to a dev repository. Right now I’m basically duplicating the Drone configs like this:
- name: publish_prod
image: plugins/gcr
pull: always
volumes:
- name: docker
path: /var/run/docker.sock
privileged: true
settings:
repo: gcr.io/blah/blah_prod
target: prod
tags:
- ${DRONE_COMMIT_SHA:0:7}
when:
branch:
- master
event:
- push
- name: publish_dev
image: plugins/gcr
pull: always
volumes:
- name: docker
path: /var/run/docker.sock
privileged: true
settings:
repo: gcr.io/blah/blah_dev
target: prod
tags:
- ${DRONE_COMMIT_SHA:0:7}
when:
branch:
exclude:
- master
event:
- push
This certainly works but I’m hoping there is a better way to do this instead of duplicating the two parts. Is there a way to provide a repo variable conditioned on the branch name or something like that?