-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from conduktor/publish_docker_image
Publish docker image
- Loading branch information
Showing
3 changed files
with
190 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Build Docker Images | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_tags: | ||
required: true | ||
type: string | ||
description: (string) Image tags to build in docker/metadata-action format | ||
release: | ||
required: false | ||
type: boolean | ||
description: (bool) Whether this is a release or not | ||
default: false | ||
push: | ||
required: false | ||
type: boolean | ||
description: (bool) Whether we should push the image or not | ||
default: true | ||
env: | ||
NAMESPACE: "conduktor" | ||
LABEL_IMAGE_AUTHORS: "Conduktor <[email protected]>" | ||
LABEL_IMAGE_DOCUMENTATION: "https://docs.conduktor.io/conduktor" | ||
LABEL_IMAGE_VENDOR: "Conduktor.io" | ||
|
||
jobs: | ||
build-docker: | ||
name: Build Platform Docker | ||
runs-on: [cdk-standard] | ||
permissions: | ||
id-token: write | ||
contents: read | ||
env: | ||
IMAGE_NAME: "conduktorctl" | ||
HARBOR_IMAGE: "harbor.cdkt.dev/conduktor/conduktorctl" | ||
LABEL_IMAGE_TITLE: "Conduktor ctl" | ||
LABEL_IMAGE_DESCRIPTION: "Conduktor command line tools" | ||
LABEL_IMAGE_URL: "https://hub.docker.com/r/conduktor/conduktorctl" | ||
steps: | ||
- name: Set up Docker Buildx | ||
id: setup-buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
version: v0.9.1 | ||
install: true | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Docker multi registries configuration | ||
id: docker_meta | ||
uses: conduktor/conduktor-actions/[email protected] | ||
with: | ||
image-name: | | ||
${{ env.IMAGE_NAME }} | ||
namespace: ${{ env.NAMESPACE }} | ||
tags: ${{ inputs.image_tags }} | ||
labels: | | ||
org.opencontainers.image.title=${{ env.LABEL_IMAGE_TITLE }} | ||
org.opencontainers.image.description=${{ env.LABEL_IMAGE_DESCRIPTION }} | ||
org.opencontainers.image.authors=${{ env.LABEL_IMAGE_AUTHORS }} | ||
org.opencontainers.image.documentation=${{ env.LABEL_IMAGE_DOCUMENTATION }} | ||
org.opencontainers.image.vendor=${{ env.LABEL_IMAGE_VENDOR }} | ||
org.opencontainers.image.url=${{ env.LABEL_IMAGE_URL }} | ||
- uses: actions/checkout@v3 | ||
- name: Build ${{ env.IMAGE_NAME }} for ${{ steps.buildx.outputs.platforms }} | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ inputs.push }} | ||
file: docker/Dockerfile | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
labels: ${{ steps.docker_meta.outputs.labels }} | ||
cache-from: type=registry,ref=${{env.HARBOR_IMAGE}}:main | ||
cache-to: type=inline,mode=min | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Release | ||
run-name: Release ${{ github.event.release.tag_name }} by ${{ github.actor }} | ||
|
||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
tags: | ||
name: List tags to be created | ||
runs-on: cdk-standard | ||
outputs: | ||
image_tags: ${{ steps.image_tag.outputs.tags }} | ||
version: ${{ steps.image_tag.outputs.version }} | ||
is_latest: ${{ steps.image_tag.outputs.is_latest }} | ||
steps: | ||
- name: Debug tags | ||
shell: bash | ||
run: | | ||
echo "----------------------------" | ||
echo "GITHUB_REF : ${GITHUB_REF}" | ||
echo "GITHUB_REF_NAME: ${GITHUB_REF_NAME}" | ||
echo "GITHUB_REF_TYPE : ${GITHUB_REF_TYPE}" | ||
echo "----------------------------" | ||
echo "Release event : " | ||
echo " name :${{ github.event.release.name }}" | ||
echo " tag_name :${{ github.event.release.tag_name }}" | ||
echo " target_commitish:${{ github.event.release.target_commitish }}" | ||
echo " draft:${{ github.event.release.draft }}" | ||
- name: Parse version from tag | ||
id: version | ||
uses: release-kit/semver@v2 | ||
with: | ||
string: '${{ github.event.release.tag_name }}' | ||
|
||
- name: Set release tag | ||
if: ${{ github.event.release }} | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
latest_release_version=$(gh release view -R ${{ github.repository }} --json tagName -q .tagName) | ||
echo "Latest release is ${latest_release}" | ||
is_latest=$(test "${{ github.event.release.tag_name }}" == "${latest_release_version}" && echo true || echo false) | ||
echo "RELEASE_TAG=${{ steps.version.outputs.full }}" >> $GITHUB_ENV | ||
echo "IS_LATEST=${is_latest}" >> $GITHUB_ENV | ||
- name: Image tag | ||
id: image_tag | ||
shell: bash | ||
run: | | ||
TAGS="" | ||
TAGS="${TAGS}type=raw,value=${{ steps.version.outputs.full }}\n" | ||
TAGS="${TAGS}type=semver,pattern={{version}}\n" | ||
TAGS="${TAGS}type=raw,value=latest,enable=${{ env.IS_LATEST }}\n" | ||
delimiter="$(openssl rand -hex 8)" | ||
echo -e "tags<<${delimiter}\n${TAGS}\n${delimiter}" >> "${GITHUB_OUTPUT}" | ||
echo -e "version=${{ steps.version.outputs.full }}" >> "${GITHUB_OUTPUT}" | ||
echo -e "is_latest=${{ env.IS_LATEST }}" >> "${GITHUB_OUTPUT}" | ||
echo "Outputs ${GITHUB_OUTPUT}" | ||
echo "-------" | ||
cat "${GITHUB_OUTPUT}" | ||
echo "-------" | ||
unit-test: | ||
runs-on: cdk-standard | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.22.0 | ||
- name: go test | ||
run: go test ./... | ||
integration-test: | ||
runs-on: cdk-standard | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: run test | ||
run: ./test_final_exec.sh | ||
|
||
build-docker: | ||
name: Build and publish conduktorctl images | ||
uses: ./.github/workflows/build-docker.yml | ||
secrets: inherit | ||
needs: [tags, unit-test, integration-test] | ||
with: | ||
release: true | ||
push: true | ||
image_tags: ${{ needs.tags.outputs.image_tags }} |