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

Make helm chart job only run if container is built ok #667

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
66 changes: 65 additions & 1 deletion .github/workflows/_container.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Build and publish container
on:
workflow_call:

env:
GCR_IMAGE: ghcr.io/diamondlightsource/blueapi
HELM_VERSION: 3.10.3

jobs:
build:
build_container:
runs-on: ubuntu-latest

steps:
Expand All @@ -11,6 +16,22 @@ jobs:
with:
# Need this to get version number from last tag
fetch-depth: 0
- name: Validate PEP 440 version compliance
run: |
python -m pip install packaging
python -c "
import re
from packaging.version import Version, InvalidVersion

ref = '${GITHUB_REF##*/}'
try:
version = Version(ref)
print(f'PEP 440 compliant version: {version}')
except InvalidVersion:
print(f'Invalid PEP 440 version: {ref}')
exit(1)
"


- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -54,3 +75,46 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

helm_publish:
name: publish gcr
runs-on: ubuntu-latest
environment: prod
needs: build_container
steps:
- name: checkout repo
uses: actions/checkout@v3

- name: install helm
uses: Azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
id: install

- name: login to acr using helm
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ${{ env.GCR_IMAGE }} --username ${{ github.repository_owner }} --password-stdin
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@57396166ad8aefe6098280995947635806a0e6ea
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag

- name: Convert PEP 440 version to SemVer
run: |
ref="${GITHUB_REF##*/}"
# Convert alpha/beta/rc versions from PEP 440 to SemVer
if [[ "$ref" =~ ([0-9]+\.[0-9]+\.[0-9]+)(a|b|rc)([0-9]+) ]]; then
ref="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}${BASH_REMATCH[3]}"
fi
echo "Converted version: $ref"
echo "VERSION=$ref" >> $GITHUB_ENV

- name: package chart and push it
run: |
sed -i "$ a appVersion: ${VERSION}" helm/blueapi/Chart.yaml
helm dependencies update helm/blueapi
helm package helm/blueapi --version ${VERSION} -d /tmp/
helm push /tmp/blueapi-${VERSION}.tgz oci://ghcr.io/diamondlightsource/charts
42 changes: 0 additions & 42 deletions .github/workflows/helm.yml

This file was deleted.

Loading