Skip to content

Merge pull request #5 from teams-notifier/crude-healthcheck #10

Merge pull request #5 from teams-notifier/crude-healthcheck

Merge pull request #5 from teams-notifier/crude-healthcheck #10

Workflow file for this run

name: "Build OCI Image"
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
jobs:
build-image:
name: "Build OCI image"
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Define TARGETS
run: |
REPOS="ghcr.io/${{ github.repository }}"
IMG_TAGS="latest"
[ ${GITHUB_REF_TYPE:-} == 'branch' ] && IMG_TAGS="$(echo $GITHUB_REF_NAME | sed -e 's,[^0-9A-Za-z_.-],-,g' | cut -c 1-128)"
if [ ${GITHUB_REF_TYPE:-} == 'tag' -a -n "$(echo $GITHUB_REF_NAME | grep -iE '^v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.-]+)?$')" ]; then
TAG=${GITHUB_REF_NAME#v}
RELEASE=""
case "$TAG" in
*-*)
RELEASE="-${TAG#*-}"
;;
esac
SEMVER_CORE="${TAG%%-*}"
IMG_TAGS="${IMG_TAGS} $TAG ${SEMVER_CORE%.*}${RELEASE} ${SEMVER_CORE%%.*}${RELEASE}"
echo "TAG=$TAG" >>$GITHUB_ENV
echo "SEMVER_CORE=$SEMVER_CORE" >>$GITHUB_ENV
fi
echo "Targets:"
TARGETS=""
for REPO in $REPOS; do
for IMG_TAG in $IMG_TAGS; do
TARGETS="${TARGETS},${REPO}:${IMG_TAG}"
echo "- ${REPO}:${IMG_TAG}"
done
done
echo TARGETS=${TARGETS#,} >>$GITHUB_ENV
echo BUILD_DATE="$(date -u -Is)" >>$GITHUB_ENV
echo COMMIT_SHA=$GITHUB_SHA >>$GITHUB_ENV
echo GITHUB_REPO="ghcr.io/${{ github.repository }}" >>$GITHUB_ENV
- uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.TARGETS }}
build-args: |
VERSION=${{ env.TAG }}
SEMVER_CORE=${{ env.SEMVER_CORE }}
BUILD_DATE=${{ env.BUILD_DATE }}
COMMIT_SHA=${{ env.COMMIT_SHA }}
GITHUB_REPO=${{ env.GITHUB_REPO }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true