Skip to content

Add github action build #4

Add github action build

Add github action build #4

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="quay.io/${{ vars.QUAYIO_USERNAME }}/kaniko-w-ecr-repo-creator ghcr.io/${{ github.repository }}"
REPOS="quay.io/${{ vars.QUAYIO_USERNAME }}/kaniko-w-ecr-repo-creator ghcr.io/babs/kaniko-w-ecr-repo-creator"
IMG_TAGS="latest"
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}"
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
- uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAYIO_ROBOT_ACCOUNTNAME }}
password: ${{ secrets.QUAYIO_ROBOT_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.TARGETS }}