Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/scripts/compute-image-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# Computes the OCI image tag for Garden Linux ccloud images
#
# This script centralizes the image tag format computation to ensure consistency
# across all workflows (nightly, dev, upload_oci).
#
# Usage:
# ./compute-image-tag.sh <version> [flavor]
#
# Arguments:
# version - The version for the tag (e.g., "1877.10.1", "pr-123")
# flavor - The image flavor (e.g., "metal-sci-usi-amd64"). Defaults to "metal-sci-usi-amd64".
#
# Environment:
# GITHUB_SHA - Git commit SHA (required, set automatically by GitHub Actions)
#
# Output:
# Prints the computed image tag to stdout
#
# Tag format:
# {version}-{flavor}-{dashed_version}-{commit_sha_short}
#
# Examples:
# ./compute-image-tag.sh "1877.10.1"
# # Output: 1877.10.1-metal-sci-usi-amd64-1877-10-1-abcd1234
#
# ./compute-image-tag.sh "pr-123" "metal-capi-amd64"
# # Output: pr-123-metal-capi-amd64-pr-123-abcd1234

set -euo pipefail

VERSION="${1:?Error: VERSION argument required}"
FLAVOR="${2:-metal-sci-usi-amd64}"

if [ -z "${GITHUB_SHA:-}" ]; then
echo "Error: GITHUB_SHA environment variable is required" >&2
exit 1
fi

COMMIT_SHA="${GITHUB_SHA::8}"
DASHED_VERSION="${VERSION//./-}"

IMAGE_TAG="${VERSION}-${FLAVOR}-${DASHED_VERSION}-${COMMIT_SHA}"

echo "$IMAGE_TAG"
12 changes: 7 additions & 5 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ jobs:
runs-on: ubuntu-latest
outputs:
UPLOAD_VERSION: ${{ steps.meta.outputs.upload_version }}
COMMIT_SHA: ${{ steps.meta.outputs.sha }}
image_tag: ${{ steps.meta.outputs.image_tag }}
steps:
- name: Derive image version
- name: Checkout
uses: actions/checkout@v4
- name: Compute image metadata
id: meta
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
UPLOAD_VERSION="pr-${PR_NUMBER}"
echo "upload_version=${UPLOAD_VERSION}" >> $GITHUB_OUTPUT
SHA="${GITHUB_SHA::8}"
echo "sha=${SHA}" >> $GITHUB_OUTPUT
IMAGE_TAG=$(.github/scripts/compute-image-tag.sh "${UPLOAD_VERSION}")
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT

upload:
name: Upload PR image to OCI
Expand All @@ -79,7 +81,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'closed' }}
uses: ./.github/workflows/test.yml
with:
image_tag: "${{ needs.meta.outputs.UPLOAD_VERSION }}-metal-sci-usi-amd64-${{ needs.meta.outputs.UPLOAD_VERSION }}-${{ needs.meta.outputs.COMMIT_SHA }}"
image_tag: ${{ needs.meta.outputs.image_tag }}

cleanup_images:
name: Cleanup PR images
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
version: ${{ inputs.version || 'now' }}
# to set target to "release" or "nightly" we need proper KMS secrets
# have a look at gardenlinux/.github/workflows/github.mjs
# have a look at gardenlinux/.github/workflows/github.mjs
target: dev
fail_fast: true
#platform_test_build: false
Expand All @@ -32,6 +32,20 @@ jobs:
# aws_kms_role: ${{ secrets.KMS_SIGNING_IAM_ROLE }}
# aws_oidc_session: ${{ secrets.AWS_OIDC_SESSION }}
# secureboot_db_kms_arn: ${{ secrets.SECUREBOOT_DB_KMS_ARN }}
meta:
name: Compute image metadata
needs: [build]
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.meta.outputs.image_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute image tag
id: meta
run: |
IMAGE_TAG=$(.github/scripts/compute-image-tag.sh "${{ needs.build.outputs.version }}")
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
upload_oci:
name: Run glcli to publish to OCI
needs: [build]
Expand All @@ -40,3 +54,9 @@ jobs:
uses: ./.github/workflows/upload_oci.yml
with:
version: ${{ needs.build.outputs.version }}
test:
name: Test nightly image
needs: [meta, upload_oci]
uses: ./.github/workflows/test.yml
with:
image_tag: ${{ needs.meta.outputs.image_tag }}
37 changes: 20 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
name: test hypervisor capabilities
on:
push:
branches:
- feat/ci-test-cloud-hypervisor
workflow_run:
workflows:
- nightly
types:
- completed
workflow_dispatch:
inputs:
image_tag:
description: "Image tag to test (must be usi-sci)"
type: string
default: ""
required: true
workflow_call:
inputs:
image_tag:
Expand All @@ -27,19 +19,30 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install oras
uses: oras-project/setup-oras@v1
with:
version: 1.2.2
- name: Validate image tag
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "Error: image_tag is required"
exit 1
fi

echo "Verifying image ${{ inputs.image_tag }} exists in GHCR..."
if ! digest=$(oras resolve ghcr.io/gardenlinux/gardenlinux-ccloud:${{ inputs.image_tag }} 2>&1); then
echo "Error: Image tag '${{ inputs.image_tag }}' not found in ghcr.io/gardenlinux/gardenlinux-ccloud"
echo "Resolve output: $digest"
exit 1
fi
echo "Image tag present in GHCR (digest: ${digest:0:12}...)"
- name: Install Dependencies
uses: ./.github/actions/test/integration/dependencies
- name: Obtain newest Tag from GHCR
id: fetch_tag
if: ${{ inputs.image_tag == '' || github.event_name == 'workflow_run' || github.event_name == 'push' }}
run: |
latest_tag=$(oras repo tags ghcr.io/gardenlinux/gardenlinux-ccloud | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-metal-sci-usi-amd64-[0-9]+-[0-9]+-[0-9]-[0-9a-f]{8}$' | sort -r | head -n 1)
echo $latest_tag
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
- name: Build
uses: ./.github/actions/test/integration/build
with:
image_tag: ${{ env.latest_tag || inputs.image_tag }}
image_tag: ${{ inputs.image_tag }}
- name: Setup
uses: ./.github/actions/test/integration/setup
- name: Test QEMU
Expand Down
Loading