Skip to content

Build and upload images #99

Build and upload images

Build and upload images #99

name: Build and upload images
on:
workflow_dispatch:
schedule:
# First day of every month, you know, for automatic updates etc.
- cron: "0 0 1 * *"
push:
branches:
- master
env:
DOCKER_BUILDKIT: 1
jobs:
build_and_upload:
name: Build and upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install regctl
run: |
set -ex
INSTALL_DIR="$HOME/.regctl"
OS=linux
ARCH=amd64
mkdir -p "$INSTALL_DIR"
# Download and Install regctl
curl -fsSL "https://github.com/regclient/regclient/releases/download/${VERSION}/regctl-${OS}-${ARCH}" > "${INSTALL_DIR}/regctl"
chmod 755 "${INSTALL_DIR}/regctl"
# Validate download
if which cosign >/dev/null; then
curl -fsSL https://github.com/regclient/regclient/releases/latest/download/metadata.tgz > metadata.tgz
tar -xzf metadata.tgz regctl-${OS}-${ARCH}.pem regctl-${OS}-${ARCH}.sig
cosign verify-blob \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp https://github.com/regclient/regclient/.github/workflows/ \
--certificate regctl-${OS}-${ARCH}.pem \
--signature regctl-${OS}-${ARCH}.sig \
"${{ inputs.install-dir }}/regctl"
rm -rf metadata.tgz regctl-${OS}-${ARCH}.pem regctl-${OS}-${ARCH}.sig
fi
# Add it to environment
echo "${INSTALL_DIR}" >> $GITHUB_PATH
env:
VERSION: v0.4.7
- name: Check regctl installation
run: regctl version
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Setup custom builder
run: |
docker buildx create --use --bootstrap --name multi-builder --platform linux/arm64,linux/amd64 --driver-opt network=host
- name: Run local Docker registry
run: docker run -d -p 5000:5000 --name registry --network=host registry:2
- name: Set up Python
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: 3.9
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install
- name: Build images
run: poetry run build_multiplatform --parallel 8
- name: Upload images
if: success()
run: |
echo "$PASSWORD" | docker login ghcr.io --username "$USERNAME" --password-stdin
poetry run upload
env:
PASSWORD: ${{ secrets.GHCR_PAT }}
USERNAME: ${{ secrets.GHCR_USERNAME }}