An CI image for updating image tags using kustomize.
Environment variables:
SSH_KEY: Base64-encoded private ssh key ofMANIFEST_USERMANIFEST_HOST: Manifest git server hostMANIFEST_USER: Manifest git user nameMANIFEST_USER_EMAIL: Manifest git user emailMANIFEST_REPO: Manifest git repositoryMANIFEST_BRANCH: Manifest repository branchIMAGES: Updated images (comma-separated list)IMAGE_TAG: Image tag generated in current buildKUSTOMIZATION: Kustomization path relative to the project root
kind: pipelinename: publish-mysvc1steps: - name: publishimage: plugins/dockersettings: context: mysvc1dockerfile: mysvc1/Dockerfileusername: from_secret: docker_usernamepassword: from_secret: docker_passwordregistry: harbor.mycompany.comrepo: harbor.mycompany.com/myuser/mysvc1tags: - ${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:7} - latestwhen: event: push --- kind: pipelinename: publish-mysvc2steps: - name: publishimage: plugins/dockersettings: context: mysvc2dockerfile: mysvc2/Dockerfileusername: from_secret: docker_usernamepassword: from_secret: docker_passwordregistry: harbor.mycompany.comrepo: harbor.mycompany.com/myuser/mysvc2tags: - ${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:7} - latestwhen: event: push --- kind: pipelinename: update-kustomizationsteps: - name: kustomizationpull: if-not-existsimage: minghsu0107/update-kustomizationenvironment: SSH_KEY: from_secret: ssh_keyMANIFEST_HOST: git.mycompany.comMANIFEST_USER: myuserMANIFEST_USER_EMAIL: [email protected]MANIFEST_REPO: myapp-manifestsMANIFEST_BRANCH: mainIMAGES: harbor.mycompany.com/myuser/mysvc1,harbor.mycompany.com/myuser/mysvc2IMAGE_TAG: ${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:7}KUSTOMIZATION: overlays/productionwhen: event: pushdepends_on: - publish-mysvc1 - publish-mysvc2In the above example, the image tag is in the form of ${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:7}, where DRONE_COMMIT_BRANCH and DRONE_COMMIT_SHA are environment variables provided by Drone at run time.