Add Helm chart #59
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Image Checks | ||
on: | ||
push: | ||
# Run only on release tags | ||
tags: | ||
- v* | ||
# or commits to main (when PRs are merged) | ||
branches: | ||
- main | ||
# but all PRs | ||
pull_request: | ||
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 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Generate Metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
- name: Build image | ||
uses: docker/build-push-action@v6 | ||
env: | ||
DOCKER_BUILD_RECORD_UPLOAD: false | ||
with: | ||
context: . | ||
cache-from: type=gha | ||
cache-to: type=gha | ||
tags: ${{ steps.meta.outputs.tags }} | ||
load: true | ||
- name: Login to GHCR | ||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io/${{ github.repository_owner }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish image | ||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
uses: docker/build-push-action@v6 | ||
env: | ||
DOCKER_BUILD_RECORD_UPLOAD: false | ||
with: | ||
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
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 | ||
Check failure on line 83 in .github/workflows/publish.yaml
|
||
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 |