Skip to content

Commit

Permalink
ci: add bundle generation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yorugac committed Jul 29, 2023
1 parent 79221ce commit e623f62
Showing 1 changed file with 72 additions and 34 deletions.
106 changes: 72 additions & 34 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
build:
name: "Build"
name: "Build images"
runs-on: ubuntu-latest
steps:
- name: "Build:checkout"
Expand All @@ -28,36 +28,74 @@ jobs:
- name: "Check image tag name"
run: |
echo "IMAGETAG=${{env.IMAGETAG}}"
- name: "Build:buildx"
uses: docker/setup-buildx-action@v1
with:
version: v0.9.1 # Buildx version
- name: "Build:login"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build:dockerimage"
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Dockerfile.controller
build-args: |
GO_BUILDER_IMG=golang:1.18
tags: ghcr.io/grafana/k6-operator:latest,ghcr.io/grafana/k6-operator:controller-${{env.IMAGETAG}}
- name: "Build:dockerimage"
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Dockerfile.runner
tags: ghcr.io/grafana/k6-operator:latest-runner,ghcr.io/grafana/k6-operator:runner-${{env.IMAGETAG}}
- name: "Build:dockerimage"
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Dockerfile.starter
tags: ghcr.io/grafana/k6-operator:latest-starter,ghcr.io/grafana/k6-operator:starter-${{env.IMAGETAG}}
# - name: "Build:buildx"
# uses: docker/setup-buildx-action@v1
# with:
# version: v0.9.1 # Buildx version
# - name: "Build:login"
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: "Build:dockerimage"
# uses: docker/build-push-action@v2
# with:
# context: .
# push: true
# file: Dockerfile.controller
# build-args: |
# GO_BUILDER_IMG=golang:1.18
# tags: ghcr.io/grafana/k6-operator:latest,ghcr.io/grafana/k6-operator:controller-${{env.IMAGETAG}}
# - name: "Build:dockerimage"
# uses: docker/build-push-action@v2
# with:
# context: .
# push: true
# file: Dockerfile.runner
# tags: ghcr.io/grafana/k6-operator:latest-runner,ghcr.io/grafana/k6-operator:runner-${{env.IMAGETAG}}
# - name: "Build:dockerimage"
# uses: docker/build-push-action@v2
# with:
# context: .
# push: true
# file: Dockerfile.starter
# tags: ghcr.io/grafana/k6-operator:latest-starter,ghcr.io/grafana/k6-operator:starter-${{env.IMAGETAG}}

bundle:
name: "Generate bundle"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: "Checkout code"
uses: actions/checkout@v2
- 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 }}

0 comments on commit e623f62

Please sign in to comment.