push snapshot container builds to branch name and releases to semver
@@ -135,7 +135,7 @@ jobs:
with:
platforms: amd64,arm64,arm
- - name: Set up builder
+ - name: Set up Docker BuildKit
id: buildx
uses: docker/setup-buildx-action@master
@@ -145,21 +145,30 @@ jobs:
username: ${{ secrets.DOCKER_HUB_API_USER }}
password: ${{ secrets.DOCKER_HUB_API_TOKEN }}
- - name: Set up image tags
+ - name: Set up Docker image tags
env:
- DOCKER_IMAGE: openziti/ziti-tunnel
+ SNAPSHOT_REPO: openziti/ziti-tunnel
+ RELEASE_REPO: netfoundry/ziti-tunnel
id: tagprep
run: |
- TAGS="${DOCKER_IMAGE}:${GITHUB_SHA::8}"
- # If this is release tag then add the semver and "latest" to image tags
- if [[ $GITHUB_REF =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ #
+ ## compose a comma-sep'd list of container image registry org/repo:tag for docker/build-push-action
+ #
+ # substitute a hyphen char for non-alnum chars in branch/ref name and drop any leading non-alnum char
+ REF_TAG="$(sed 's/[^a-zA-Z0-9]/-/g;s/^[^a-zA-Z0-9]//'' <<< "${GITHUB_REF}" | tr '[:upper:]' '[:lower:]')"
+ TAGS="${SNAPSHOT_REPO}:${REF_TAG}"
+ # If this is release tag then add the release repo and semver and "latest" to the list of tags
+ if [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ # drop the prefix, preserving the semver
ZITI_VERSION=${GITHUB_REF#refs/tags/v}
- TAGS+=",${DOCKER_IMAGE}:${ZITI_VERSION},${DOCKER_IMAGE}:latest"
+ for REPO in ${SNAPSHOT_REPO} ${RELEASE_REPO}; do
+ TAGS+=",${REPO}:${ZITI_VERSION},${REPO}:latest"
+ done
fi
# Set output parameters.
echo ::set-output name=tags::${TAGS}
- - name: Build & Push Container Image to Hub
+ - name: Build & Push Multi-Platform Container Image to Hub
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
