Skip to content

zbchaos-v1.4.1

zbchaos-v1.4.1 #487

name: Release zbchaos Docker Image
on:
pull_request: {}
push:
branches: [ main ]
release:
types: [published]
jobs:
publish-image:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Collect image tags
uses: actions/github-script@v6
id: image-tags
with:
# language=javascript
script: |
// noinspection JSUnresolvedVariable
const imageName = `gcr.io/zeebe-io/zbchaos`
const versionRegex = /zbchaos-v(?<version>\d+\.\d+\.\d+)/i
if (context.eventName === "release") {
const versionMatch = context.payload.release.name.match(versionRegex)
if (versionMatch == null) {
core.warning(`Release was published but not detected as a zbchaos release. Tagging image only with sha ${context.sha}`)
return `${imageName}:${context.sha}`
}
// For releases, tag with release version, sha and 'latest'
let version = versionMatch.groups["version"];
core.info(`Detected zbchaos release ${version}, tagging image ${imageName} with ${version}, 'latest' and sha ${context.sha}`)
return `${imageName}:${version},${imageName}:latest,${imageName}:${context.sha}`
} else {
// If not a release, tag only with sha
return `${imageName}:${context.sha}`
}
result-encoding: string
- name: Setup BuildKit
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.DOCKER_GCR }}
- name: Publish Docker Image
uses: docker/build-push-action@v3
with:
context: go-chaos
push: true
tags: ${{ steps.image-tags.outputs.result }}
cache-from: type=gha
cache-to: type=gha,mode=max