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

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
55 changes: 53 additions & 2 deletions .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,7 +16,19 @@ jobs:
with:
# Need this to get version number from last tag
fetch-depth: 0

- name: Validate SemVer2 version compliance
if: startsWith(github.ref, 'refs/tags/')
env:
SEMVER_REGEX: ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$
run: |
ref="${{ github.ref_name }}"
my_regex="${{env.SEMVER_REGEX}}"
if [[ "$ref" =~ $my_regex ]]; then
echo "SemVer compliant version: $ref"
else
echo "Invalid SemVer version: $ref"
exit 1
fi
callumforrester marked this conversation as resolved.
Show resolved Hide resolved
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -54,3 +71,37 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

helm_publish:
name: publish gcr
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
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 gcr 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: 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