Skip to content

Commit 60b42b2

Browse files
refactor: Adjust Helm push (#25)
1 parent ae0bbd7 commit 60b42b2

File tree

2 files changed

+44
-33
lines changed

2 files changed

+44
-33
lines changed

.github/workflows/_container.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,44 @@ jobs:
99
uses: actions/checkout@v4
1010
with:
1111
persist-credentials: false
12-
1312

14-
1513
- name: Generate Metadata
1614
id: meta
17-
uses: docker/metadata-action@v5
15+
uses: docker/metadata-action@v5
1816
with:
1917
images: ghcr.io/${{ github.repository }}
20-
21-
# - name: Build image
22-
# uses: docker/build-push-actions@v6
23-
18+
tags: |
19+
type=raw,value=latest
20+
type=semver,pattern={{version}}
21+
type=semver,pattern={{major}}.{{minor}}
22+
type=semver,pattern={{major}}
23+
24+
- name: Build and export to Docker local cache
25+
uses: docker/build-push-action@v6
26+
env:
27+
DOCKER_BUILD_RECORD_UPLOAD: false
28+
with:
29+
# Need load and tags so we can test it below
30+
load: true
31+
tags: test_tag
32+
33+
- name: Test cli works in cached runtime image
34+
run: docker run --rm test_tag --version
35+
2436
- name: Log in to GHCR
25-
# if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
2637
uses: docker/login-action@v3
2738
with:
2839
registry: ghcr.io/${{ github.repository_owner }}
2940
username: ${{ github.actor }}
3041
password: ${{ secrets.GITHUB_TOKEN }}
3142

32-
- name: Publish image
43+
# This does not build the image again, it will find the image in the
44+
# Docker cache and publish it
45+
- name: Push cached image to container registry
3346
uses: docker/build-push-action@v6
3447
env:
3548
DOCKER_BUILD_RECORD_UPLOAD: false
3649
with:
37-
# push: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
38-
push: true
39-
tags: ${{ steps.meta.outputs.tags }}
50+
push: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/_helm.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,29 @@ jobs:
1414
fetch-depth: 0
1515
persist-credentials: false
1616

17-
- name: Install helm
18-
uses: Azure/setup-helm@v3
17+
- name: Generate Metadata
18+
id: meta
19+
uses: docker/metadata-action@v5
20+
with:
21+
tags: |
22+
type=semver,pattern={{version}}
1923
20-
# Check that alpha/beta versions have the form X.Y.Z-alpha.A requried by Helm.
21-
# An early check saves waiting for the entire build before finding a problem.
22-
- name: Check helm version tag
23-
if: ${{ github.ref_type == 'tag' }}
24-
env:
25-
VERSION: "${{ github.ref_name }}"
26-
run: |
27-
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+((-alpha|-beta|-rc)\.[0-9]+)?$ ]]; then
28-
echo "Valid version format: '${VERSION}'"
29-
else
30-
echo "Invalid version: '${VERSION}'. Expected: 'X.Y.Z' or 'X.Y.Z-beta.1' or 'X.Y.Z-alpha.1'"
31-
exit 1
32-
fi
24+
- name: Install helm
25+
uses: Azure/setup-helm@v4
3326

34-
35-
- name: login to gcr using helm
27+
- name: Login to chart registry
3628
run: |
3729
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.repository_owner }} --password-stdin
3830
39-
40-
- name: package chart and push it
31+
- name: Package chart
4132
run: |
4233
helm dependencies update Charts/glazed
43-
helm package Charts/glazed --version ${GITHUB_REF##*/} --app-version ${GITHUB_REF##*/} -d /tmp/
44-
helm push /tmp/glazed-${GITHUB_REF##*/}.tgz oci://ghcr.io/diamondlightsource/charts
34+
helm package Charts/glazed --version "${{ steps.meta.outputs.version }}" --app-version "${{ steps.meta.outputs.version }}" -d /tmp/
35+
36+
- name: Publish chart
37+
env:
38+
REPO: ${{ github.repository_owner }}
39+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
40+
# Helm push requires the registry name is all lowercase
41+
run: |
42+
helm push /tmp/glazed-*.tgz oci://ghcr.io/${REPO@L}/charts

0 commit comments

Comments
 (0)