Build AmazonLinux Images #308
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build AmazonLinux Images | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Build amd64 (Daily at 00:00 UTC). | |
- cron: '0 0 * * 1' # Build arm64 (Weekly on Monday at 00:00 UTC). | |
workflow_dispatch: | |
inputs: | |
publish: | |
type: boolean | |
default: false | |
description: Publish built image | |
build-arm64: | |
type: boolean | |
default: false | |
description: Build arm64 images | |
jobs: | |
amazonlinux: | |
if: github.event_name != 'schedule' || github.repository == 'canonical/lxd-ci' | |
runs-on: ${{ matrix.architecture == 'arm64' && 'Ubuntu_ARM64_4C_16G_01' || 'ubuntu-20.04' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
release: | |
- 2 # Requires cgroups v1 for tests. They will pass on ubuntu-20.04 runner. | |
- 2023 | |
variant: | |
- default | |
architecture: | |
- ${{ (inputs.build-arm64 == true || github.event.schedule == '0 0 * * 1') && 'arm64' ||'amd64' }} | |
exclude: | |
- {architecture: arm64, release: 2} | |
env: | |
type: "container" | |
distro: "${{ github.job }}" | |
target: "${HOME}/build" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup environment | |
uses: ./.github/actions/image-setup | |
- name: Build image | |
run: | | |
TIMEOUT=1800 | |
YAML="${{ github.workspace }}/images/${{ env.distro }}.yaml" | |
ARCH="${{ matrix.architecture }}" | |
TYPE="${{ env.type }}" | |
RELEASE="${{ matrix.release }}" | |
IMAGE_ARCH="${ARCH}" | |
[ "${ARCH}" = "amd64" ] && IMAGE_ARCH="x86_64" | |
[ "${ARCH}" = "arm64" ] && IMAGE_ARCH="aarch64" | |
if [ ${RELEASE} = "2" ]; then | |
URL="https://cdn.amazonlinux.com/os-images" | |
REL=$(curl -sI https://cdn.amazonlinux.com/os-images/latest/ | sed -En 's/location:.*os-images\/([^\/]+)\/.*/\1/p') | |
if [ "${ARCH}" = "amd64" ]; then | |
URL="${URL}/${REL}/container/amzn2-container-raw-${REL}-x86_64.tar.xz" | |
elif [ "${ARCH}" = "arm64" ]; then | |
URL="${URL}/${REL}/container-arm64/amzn2-container-raw-${REL}-arm64.tar.xz" | |
fi | |
fi | |
if [ ${RELEASE} = "2023" ]; then | |
URL="https://cdn.amazonlinux.com/al2023/os-images" | |
REL="2023.2.20231113.0" | |
if [ "${ARCH}" = "amd64" ]; then | |
URL="${URL}/${REL}/container/al2023-container-${REL}-x86_64.tar.xz" | |
elif [ "${ARCH}" = "arm64" ]; then | |
URL="${URL}/${REL}/container-arm64/al2023-container-${REL}-arm64.tar.xz" | |
fi | |
fi | |
./bin/build-distro "${YAML}" "${ARCH}" "${TYPE}" "${TIMEOUT}" "${{ env.target }}" \ | |
-o image.architecture="${IMAGE_ARCH}" \ | |
-o image.release=${{ matrix.release }} \ | |
-o image.variant=${{ matrix.variant }} \ | |
-o source.url="${URL}" | |
- name: Print build artifacts | |
run: ls -lah "${{ env.target }}" | |
- name: Test container image | |
uses: ./.github/actions/image-test | |
if: contains(env.type, 'container') | |
with: | |
type: container | |
target: ${{ env.target }} | |
distro: ${{ env.distro }} | |
release: ${{ matrix.release }} | |
variant: ${{ matrix.variant }} | |
- name: Test VM image | |
uses: ./.github/actions/image-test | |
if: contains(env.type, 'vm') | |
with: | |
type: vm | |
target: ${{ env.target }} | |
distro: ${{ env.distro }} | |
release: ${{ matrix.release }} | |
variant: ${{ matrix.variant }} | |
- name: Upload image | |
uses: ./.github/actions/image-upload | |
if: github.event_name == 'schedule' || inputs.publish == true | |
with: | |
target: ${{ env.target }} | |
image_dir: "${{ env.distro }}/${{ matrix.release }}/${{ matrix.architecture }}/${{ matrix.variant }}" | |
ssh_private_key: "${{ secrets.LXD_INFRA_IMAGES_KEY }}" |