Skip to content

Commit

Permalink
ci: inject dockerfile dependency versions from workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zerok committed Nov 25, 2024
1 parent fb6380f commit ccffb83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,30 @@ env:
type=semver,pattern={{version}},value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
jobs:
determine-versions:
runs-on: ubuntu-latest
steps:
- name: "Determine dependency versions"
id: "versions"
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const helmRelease = await github.rest.repos.getLatestRelease({
'owner': 'helm',
'repo': 'helm',
});
core.setOutput('helm', helmRelease.tag_name);
const kustomizeReleases = await github.rest.repos.listRelease({
'owner': 'helm',
'repo': 'helm',
});
const kustomizeRelease = kustomizeReleases
.filter(release => release.tag_name.startsWith('kustomize'))[0];
core.setOutput('helm', kustomizeRelease.tag_name);
build:
needs:
- determine-versions
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -66,6 +89,9 @@ jobs:
context: .
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name == 'push' }}
build-args: |
HELM_VERSION=${{ needs.determine-versions.outputs.helm }}
KUSTOMIZE_VERSION=${{ needs.determine-versions.outputs.kubectl }}
- name: Export digest
id: digest
Expand Down
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,22 @@ RUN apk add --no-cache git make bash &&\

FROM golang:1.23.3-alpine AS helm
WORKDIR /tmp/helm
ARG HELM_VERSION
RUN apk add --no-cache jq curl
RUN export TAG=$(curl --silent "https://api.github.com/repos/helm/helm/releases/latest" | jq -r .tag_name) &&\
export OS=$(go env GOOS) &&\
export ARCH=$(go env GOARCH) &&\
curl -SL "https://get.helm.sh/helm-${TAG}-${OS}-${ARCH}.tar.gz" > helm.tgz && \
RUN curl -SL "https://get.helm.sh/helm-${HELM_VERSION}-${OS}-${ARCH}.tar.gz" > helm.tgz && \
tar -xvf helm.tgz --strip-components=1

FROM golang:1.23.3-alpine AS kustomize
WORKDIR /tmp/kustomize
ARG KUSTOMIZE_VERSION
RUN apk add --no-cache jq curl
# Get the latest version of kustomize
# Releases are filtered by their name since the kustomize repository exposes multiple products in the releases
RUN export TAG=$(curl --silent "https://api.github.com/repos/kubernetes-sigs/kustomize/releases" | jq -r '[ .[] | select(.name | startswith("kustomize")) ] | .[0].tag_name') &&\
export VERSION_TAG=${TAG#*/} &&\
RUN export VERSION_TAG=${KUSTOMIZE_VERSION#*/} &&\
export OS=$(go env GOOS) &&\
export ARCH=$(go env GOARCH) &&\
echo "https://github.com/kubernetes-sigs/kustomize/releases/download/${TAG}/kustomize_${VERSION_TAG}_${OS}_${ARCH}.tar.gz" && \
curl -SL "https://github.com/kubernetes-sigs/kustomize/releases/download/${TAG}/kustomize_${VERSION_TAG}_${OS}_${ARCH}.tar.gz" > kustomize.tgz && \
echo "https://github.com/kubernetes-sigs/kustomize/releases/download/${KUSTOMIZE_VERSION}/kustomize_${VERSION_TAG}_${OS}_${ARCH}.tar.gz" && \
curl -SL "https://github.com/kubernetes-sigs/kustomize/releases/download/${KUSTOMIZE_VERSION}/kustomize_${VERSION_TAG}_${OS}_${ARCH}.tar.gz" > kustomize.tgz && \
tar -xvf kustomize.tgz

FROM golang:1.23.3 AS build
Expand Down

0 comments on commit ccffb83

Please sign in to comment.