Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow proposal #41

Merged
merged 4 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/helm-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint and validate Helm chart
on:
pull_request:
types: [opened, reopened, edited]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup helm
uses: azure/setup-helm@v3
with:
version: 'v3.10.0'
id: install-helm

- name: Test helm
run: helm template helm-charts/k8s-mediaserver
72 changes: 72 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build and Push Image
on:
push:
branches:
- master

jobs:
versioning:
name: Check and manage versioning
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.bump-version.outputs.new_tag || steps.bump-version.outputs.previous_tag }}

steps:
- uses: actions/checkout@v3

- name: Bump version and push tag
uses: mathieudutour/[email protected]
id: bump-version
with:
github_token: ${{ secrets.GH_TOKEN }}
default_bump: false
Copy link
Contributor

@InputObject2 InputObject2 Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container image would be changing and I don't think we want to overwrite existing image versions, why not generate a new patch version on each push to master?

This way we can stop manually bumping the version in the dockerfile and let Github handle the versionning.

Suggested change
default_bump: false
default_bump: patch

or just remove default_bump altogether since it's the default value

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since every PR will need validation and approval, I think it's a good idea to keep control over the version increase and only bump the image if strictly necessary.
In my mind, a change in the README cannot be considered a version bump, or a typo in a description.
We could add a check, like "if the new tag is undefined, don't run the build job" but rebuilding and pushing the image won't affect the existing one.

Adding a variable in the helm chart is, as the image will be different, a new tag must be generated and a new image will be built and pushed.


build_image:
needs: versioning
name: Build and push container images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build Image - x86_64
id: build-image-x86_64
uses: redhat-actions/buildah-build@v2
with:
image: k8s-mediaserver-operator
tags: latest ${{ needs.versioning.outputs.release_tag }}
containerfiles: |
./Dockerfile

- name: Build Image - ARM64
id: build-image-arm64
uses: redhat-actions/buildah-build@v2
with:
image: k8s-mediaserver-operator
tags: latest-arm64 ${{ needs.versioning.outputs.release_tag }}-arm64
containerfiles: |
./Dockerfile-arm64

- name: Push To quay.io
id: push-x86
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image-x86_64.outputs.image }}
tags: latest ${{ needs.versioning.outputs.release_tag }}
registry: quay.io/kubealex
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Push To quay.io
id: push-arm64
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image-arm64.outputs.image }}
tags: latest-arm64 ${{ needs.versioning.outputs.release_tag }}-arm64
registry: quay.io/kubealex
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Print image url
run: echo "Images pushed to {{ steps.push-x86.outputs.registry-paths }} and ${{ steps.push-arm64.outputs.registry-paths }}"