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

Tidy Helm action #771

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
46 changes: 9 additions & 37 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_call:

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

jobs:
Expand All @@ -16,20 +16,7 @@ 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
Comment on lines -19 to -32
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, I would like proof we don't need this

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -61,6 +48,7 @@ jobs:
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=ref,event=tag
type=raw,value=latest

Expand All @@ -77,36 +65,20 @@ jobs:
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
- name: Install Helm
uses: Azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
id: install

- name: login to gcr using helm
- name: Log in to GitHub Container Registry
if: github.ref_type == 'tag'
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
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ${{ env.GHCR_IMAGE }} --username ${{ github.repository_owner }} --password-stdin

- name: package chart and push it
if: github.ref_type == 'tag'
run: |
sed -i "$ a appVersion: ${GITHUB_REF##*/}" helm/blueapi/Chart.yaml
helm dependencies update helm/blueapi
helm package helm/blueapi --version ${GITHUB_REF##*/} -d /tmp/
helm push /tmp/blueapi-${GITHUB_REF##*/}.tgz oci://ghcr.io/diamondlightsource/charts
helm package helm/blueapi --version ${{ steps.meta.outputs.version }} --app-version ${{ steps.meta.outputs.version }} -d /tmp/
helm push /tmp/blueapi-${{ steps.meta.outputs.version }}.tgz oci://ghcr.io/diamondlightsource/charts
Loading