Release k6-operator #55
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: "Release k6-operator" | |
on: | |
workflow_dispatch: | |
inputs: | |
image_tag: | |
description: "Image tag name." | |
required: true | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
name: "Build images" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Build:checkout" | |
uses: actions/checkout@v4 | |
- name: "Set image tag name" | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "IMAGETAG=${{ github.event.inputs.image_tag }}" >> $GITHUB_ENV | |
else | |
echo "IMAGETAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
fi | |
- name: "Check image tag name" | |
run: | | |
echo "IMAGETAG=${{env.IMAGETAG}}" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: "Build:buildx" | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: v0.9.1 # Buildx version | |
- name: "Build:login" | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build:dockerimage" | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
file: Dockerfile.controller | |
build-args: | | |
GO_BUILDER_IMG=golang:1.22 | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/grafana/k6-operator:latest,ghcr.io/grafana/k6-operator:controller-${{env.IMAGETAG}} | |
- name: "Build:dockerimage" | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
file: Dockerfile.runner | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/grafana/k6-operator:latest-runner,ghcr.io/grafana/k6-operator:runner-${{env.IMAGETAG}} | |
- name: "Build:dockerimage" | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
file: Dockerfile.starter | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/grafana/k6-operator:latest-starter,ghcr.io/grafana/k6-operator:starter-${{env.IMAGETAG}} | |
bundle: | |
name: "Generate bundle" | |
if: startsWith(github.ref_name, 'v') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Set image tag name" | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "IMAGETAG=${{ github.event.inputs.image_tag }}" >> $GITHUB_ENV | |
else | |
echo "IMAGETAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
fi | |
- name: "Setup kustomize" | |
uses: imranismail/setup-kustomize@v2 | |
- name: "Bundle" | |
run: | | |
cd config/default && kustomize edit set image ghcr.io/grafana/k6-operator=*:controller-${{env.IMAGETAG}} && kustomize build . > ../../bundle.yaml | |
- name: "Branch" | |
run: | | |
git checkout -b release-${{env.IMAGETAG}}/bundle-update | |
git add bundle.yaml | |
git diff --cached | tee diff.file | |
echo "BUNDLE_DIFF=$(wc -c < diff.file)" >> "$GITHUB_OUTPUT" | |
- name: "Make PR" | |
if: ${{ steps.branch.BUNDLE_DIFF }} > 0 | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git commit -m 'auto: bundle update for ${{env.IMAGETAG}}' | |
git push -u origin release-${{env.IMAGETAG}}/bundle-update | |
gh pr create --title "Bundle update for release ${{env.IMAGETAG}}" -B main -H release-${{env.IMAGETAG}}/bundle-update --body "Auto-generated by Github Workflow" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |