Skip to content

Commit

Permalink
Add publish actions
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Dec 19, 2024
1 parent 3e75965 commit 38e57af
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ jobs:
build:
runs-on: ubuntu-latest
steps:

# Validate that the Image is published with a tag that is a valid SemVer, required by Helm chart
- name: Validate SemVer2 version compliance
if: startsWith(github.ref, 'refs/tags/')
env:
SEMVER_REGEX: ^v?(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
- name: Checkout
uses: actions/checkout@v4

Expand Down Expand Up @@ -59,3 +76,33 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
push: true


build-and-publish-chart:
runs-on: ubuntu-latest
needs: build-and-push-image
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: |
helm dependencies update helm/numtracker
helm package helm/numtracker --version ${GITHUB_REF##*/?(v)} --app-version ${GITHUB_REF##*/} -d /tmp/
helm push /tmp/numtracker-${GITHUB_REF##*/?(v)}.tgz oci://ghcr.io/diamondlightsource/charts

0 comments on commit 38e57af

Please sign in to comment.