Merge pull request #17 from devops-ia/feat/upgrade-cruise-control-cc2… #83
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
name: Create Cruise Control release | |
env: | |
DOCKERHUB_USER: devopsiaci | |
DOCKERHUB_REPO: cruise-control | |
GHCR_REGISTRY: ghcr.io | |
GHCR_REPO: ${{ github.repository }} | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- Dockerfile | |
jobs: | |
release: | |
name: Create tag release | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
jdk_version: [11, 17] | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
attestations: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Read tags from Dockerfile | |
id: current_tag | |
run: | | |
# cc_tag | |
cc_current_tag=$(grep "ARG CC_TAG" Dockerfile | cut -d '=' -f 2) | |
echo "cc_current_tag=$cc_current_tag" >> $GITHUB_OUTPUT | |
# cc_ui_tag | |
cc_ui_current_tag=$(grep "ARG CC_UI_TAG" Dockerfile | cut -d '=' -f 2) | |
echo "cc_ui_current_tag=$cc_ui_current_tag" >> $GITHUB_OUTPUT | |
# iam_tag | |
iam_current_tag=$(grep "ARG AWS_MSK_IAM_AUTH_VERSION" Dockerfile | cut -d '=' -f 2) | |
echo "iam_current_tag=$iam_current_tag" >> $GITHUB_OUTPUT | |
# complete tag | |
echo "complete_tag=jdk${{ matrix.jdk_version }}-cc$cc_current_tag-iam$iam_current_tag" >> $GITHUB_OUTPUT | |
- name: "Set Docker metadata" | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPO }} | |
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPO }} | |
labels: | | |
org.opencontainers.image.maintainer=ialejandro | |
org.opencontainers.image.title=Cruise Control | |
org.opencontainers.image.description=Cruise Control for Apache Kafka | |
org.opencontainers.image.vendor=DevOps IA | |
tags: | | |
type=raw,value=${{ steps.current_tag.outputs.complete_tag }} | |
type=sha,enable=false | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: "[DOCKERHUB] Log in to Docker Hub" | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: "[GHCR] Log in to the Container registry" | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GHCR_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build and push Docker image" | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: OPENJDK_VERSION=${{ matrix.jdk_version }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
context: . | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
sbom: true | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: "Update README.md default version" | |
run: | | |
# replace default version | |
sed -i "s/\* Cruise Control: .*/* Cruise Control: \`${{ steps.current_tag.outputs.cc_current_tag }}\`/" README.md | |
sed -i "s/\* Cruise Control UI: .*/* Cruise Control UI: \`${{ steps.current_tag.outputs.cc_ui_current_tag }}\`/" README.md | |
sed -i "s/\* AWS IAM Auth: .*/* AWS IAM Auth: \`${{ steps.current_tag.outputs.iam_current_tag }}\`/" README.md | |
# push changes | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git add README.md | |
git commit -m "chore: update README.md [skip ci]" || true | |
git push -f origin HEAD:main | |
- name: "[DOCKERHUB] Update Docker registry description" | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: ${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPO }} | |
- name: "[GHCR] Generate artifact" | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPO }} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true | |
- # Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |