Skip to content

Merge pull request #550 from cnvergence/pin-gh-actions #199

Merge pull request #550 from cnvergence/pin-gh-actions

Merge pull request #550 from cnvergence/pin-gh-actions #199

Workflow file for this run

name: Image
on:
push:
tags:
- 'v*'
branches:
- main
permissions:
contents: read
packages: write
id-token: write
jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: v1.26.2
check-latest: true
# We need this to remove local tags that are not semver so goreleaser doesn't get confused.
- name: Delete non-semver tags
run: 'git tag -d $(git tag -l | grep -v "^v")'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
# If you notice signing errors, you may need to update the cosign version.
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Install Helm
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
with:
version: 'v3.12.0'
- name: Compute build env
run: |
{
echo "LDFLAGS=$(make ldflags)"
echo "IMAGE_REPO=ghcr.io/${{ github.repository_owner }}"
echo "IMAGE_TAGS=latest ${{ github.sha }} 0.0.0-${{ github.sha }} ${{ github.ref_name }}"
echo "BUILDX_CACHE_FROM=type=gha"
echo "BUILDX_CACHE_TO=type=gha,mode=max"
echo "COSIGN_ARGS=-a sha=${{ github.sha }} -a ref=${{ github.ref }} -a run_id=${{ github.run_id }} -a run_attempt=${{ github.run_attempt }}"
} >> "$GITHUB_ENV"
# Common OCI labels (one per line so build-image.sh can split on newlines)
{
echo 'IMAGE_LABELS<<EOF'
echo "org.opencontainers.image.source=https://github.com/${{ github.repository }}"
echo "org.opencontainers.image.revision=${{ github.sha }}"
echo "org.opencontainers.image.version=${{ github.ref_name }}"
echo 'EOF'
} >> "$GITHUB_ENV"
# Helm chart version: semver from tag, otherwise 0.0.0-<sha>
if [[ "${{ github.ref_type }}" == "tag" ]]; then
chart_version="${{ github.ref_name }}"
echo "CHART_VERSION=${chart_version#v}" >> "$GITHUB_ENV"
else
echo "CHART_VERSION=0.0.0-${{ github.sha }}" >> "$GITHUB_ENV"
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GHCR for Helm
env:
HELM_EXPERIMENTAL_OCI: '1'
run: echo "${{ github.token }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Build, push, and sign images
run: make release-images
- name: Build and push Helm charts
run: make release-helm
- uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0
with:
package-name: '${{ github.event.repository.name }}'
package-type: 'container'
min-versions-to-keep: 10
delete-only-pre-release-versions: "true"