chore: support sharing matrix outputs #1135
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 Images | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 */12 * * *" | |
workflow_dispatch: | |
env: | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
OUTPUTS_FILE: /tmp/matrix-outputs.txt | |
jobs: | |
build-base: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
fedora-version: [39, 40, stable] | |
fedora-edition: [base, silverblue, kinoite] | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
env: | |
IMAGE_NAME: eternal-linux/main/${{ matrix.fedora-edition }} | |
FEDORA_VERSION: ${{ matrix.fedora-version }} | |
COREOS_KERNEL: "N/A" | |
outputs: | |
base-image-tag: ${{ steps.generate-image-tags.outputs.primary-tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Optimize GHA Storage | |
uses: ./.github/actions/optimise-gha-storage | |
- name: Generate Image Tags | |
uses: ./.github/actions/generate-image-tags | |
id: generate-image-tags | |
with: | |
image-name: ${{ env.IMAGE_REGISTRY}}/${{ env.IMAGE_NAME }} | |
major-version: ${{ env.FEDORA_VERSION }} | |
is-release: ${{ github.event_name != 'pull_request' }} | |
- name: Get CoreOS Kernel Information | |
if: ${{ env.FEDORA_VERSION == 'stable' || env.FEDORA_VERSION == 'testing' }} | |
uses: ./.github/actions/get-coreos-kernel | |
id: get-coreos-kernel | |
with: | |
coreos-stream: ${{ env.FEDORA_VERSION }} | |
- name: Set CoreOS Environment Variables | |
if: ${{ env.FEDORA_VERSION == 'stable' || env.FEDORA_VERSION == 'testing' }} | |
run: | | |
echo "COREOS_KERNEL=${{ steps.get-coreos-kernel.outputs.coreos-kernel-release }}" >> $GITHUB_ENV | |
echo "FEDORA_VERSION=${{ steps.get-coreos-kernel.outputs.coreos-repo-version }}" >> $GITHUB_ENV | |
- name: Build Image | |
id: build | |
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2 | |
with: | |
context: . | |
containerfiles: | | |
Containerfile | |
image: ${{ env.IMAGE_NAME }} | |
tags: | | |
${{ steps.generate-image-tags.outputs.tags }} | |
build-args: | | |
FEDORA_VERSION=${{ env.FEDORA_VERSION }} | |
FEDORA_EDITION=${{ matrix.fedora-edition }} | |
COREOS_KERNEL=${{ env.COREOS_KERNEL }} | |
- name: Push Image | |
id: push | |
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2 | |
with: | |
image: ${{ steps.build.outputs.image }} | |
tags: ${{ steps.build.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to GHCR | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Sign Image | |
uses: ./.github/actions/sign-image | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} | |
digest: ${{ steps.push.outputs.digest }} | |
private-key: ${{ secrets.ETERNAL_LINUX_SIGNING_KEY }} | |
private-key-passphrase: ${{ secrets.ETERNAL_LINUX_SIGNING_KEY_PASSPHRASE }} | |
- name: Create Outputs File | |
id: create-outputs-file | |
run: | | |
echo "DIGEST=${{ steps.push.outputs.digest }}" >> $OUTPUTS_FILE | |
echo "IMAGE_NAME=${{ env.IMAGE_NAME }}" >> $OUTPUTS_FILE | |
ARTIFACT_NAME="outputs-${{ env.IMAGE_NAME }}-${{ matrix.image-flavour }}-${{ matrix.fedora-version }}" | |
echo "ARTIFACT_NAME=${ARTIFACT_NAME//\//-}" >> $GITHUB_OUTPUT | |
- name: Upload Outputs File | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.create-outputs-file.outputs.ARTIFACT_NAME }} | |
if-no-files-found: error | |
path: ${{ env.OUTPUTS_FILE }} | |
build-nvidia: | |
runs-on: ubuntu-latest | |
needs: build-base | |
if: ${{ !cancelled() }} | |
strategy: | |
fail-fast: false | |
matrix: | |
fedora-version: [39, 40, stable] | |
fedora-edition: [base, silverblue, kinoite] | |
nvidia-version: [550] | |
include: | |
- nvidia-version: 550 | |
nvidia-is-stable: true | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
env: | |
IMAGE_NAME: eternal-linux/main/${{ matrix.fedora-edition }} | |
FEDORA_VERSION: ${{ matrix.fedora-version }} | |
COREOS_KERNEL: "N/A" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Optimize GHA Storage | |
uses: ./.github/actions/optimise-gha-storage | |
- name: Generate Image Tags | |
uses: ./.github/actions/generate-image-tags | |
id: generate-image-tags | |
with: | |
image-name: ${{ env.IMAGE_REGISTRY}}/${{ env.IMAGE_NAME }} | |
major-version: ${{ env.FEDORA_VERSION }} | |
is-release: ${{ github.event_name != 'pull_request' }} | |
nvidia-driver-version: ${{ matrix.nvidia-version }} | |
nvidia-driver-is-stable: ${{ matrix.nvidia-is-stable }} | |
- name: Get CoreOS Kernel Information | |
if: ${{ env.FEDORA_VERSION == 'stable' || env.FEDORA_VERSION == 'testing' }} | |
uses: ./.github/actions/get-coreos-kernel | |
id: get-coreos-kernel | |
with: | |
coreos-stream: ${{ env.FEDORA_VERSION }} | |
- name: Set CoreOS Environment Variables | |
if: ${{ env.FEDORA_VERSION == 'stable' || env.FEDORA_VERSION == 'testing' }} | |
run: | | |
echo "COREOS_KERNEL=${{ steps.get-coreos-kernel.outputs.coreos-kernel-release }}" >> $GITHUB_ENV | |
echo "FEDORA_VERSION=${{ steps.get-coreos-kernel.outputs.coreos-repo-version }}" >> $GITHUB_ENV | |
- name: Generate Base Image Tag | |
id: generate-base-image-tag | |
env: | |
BASE_FEDORA_VERSION: ${{ matrix.fedora-version }} | |
PR_NUMBER: ${{ github.event.number }} | |
IS_PR: ${{ github.event_name == 'pull_request' }} | |
run: | | |
GIT_SHA=$(git rev-parse --short HEAD) | |
if [ $IS_PR == 'true' ]; then | |
BASE_TAG="pr${PR_NUMBER}-${GIT_SHA}-${BASE_FEDORA_VERSION}" | |
else | |
BASE_TAG="${GIT_SHA}-${BASE_FEDORA_VERSION}" | |
fi | |
echo "base-tag=${BASE_TAG}" >> $GITHUB_OUTPUT | |
- name: Build Image | |
id: build | |
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2 | |
with: | |
context: . | |
containerfiles: | | |
Containerfile.nvidia | |
image: ${{ env.IMAGE_NAME }} | |
tags: | | |
${{ steps.generate-image-tags.outputs.tags }} | |
build-args: | | |
FEDORA_VERSION=${{ env.FEDORA_VERSION }} | |
FEDORA_EDITION=${{ matrix.fedora-edition }} | |
NVIDIA_VERSION=${{ matrix.nvidia-version }} | |
BASE_TAG=${{ steps.generate-base-image-tag.outputs.base-tag }} | |
NVIDIA_AKMODS_TAG=${{ matrix.fedora-version }}-${{ matrix.nvidia-version }} | |
- name: Push Image | |
id: push | |
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2 | |
with: | |
image: ${{ steps.build.outputs.image }} | |
tags: ${{ steps.build.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to GHCR | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Sign Image | |
uses: ./.github/actions/sign-image | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} | |
digest: ${{ steps.push.outputs.digest }} | |
private-key: ${{ secrets.ETERNAL_LINUX_SIGNING_KEY }} | |
private-key-passphrase: ${{ secrets.ETERNAL_LINUX_SIGNING_KEY_PASSPHRASE }} | |
- name: Create Outputs File | |
id: create-outputs-file | |
run: | | |
echo "DIGEST=${{ steps.push.outputs.digest }}" >> $OUTPUTS_FILE | |
echo "IMAGE_NAME=${{ env.IMAGE_NAME }}" >> $OUTPUTS_FILE | |
ARTIFACT_NAME="outputs-${{ env.IMAGE_NAME }}-${{ matrix.image-flavour }}-${{ matrix.fedora-version }}-nvidia${{ matrix.nvidia-version }}" | |
echo "ARTIFACT_NAME=${ARTIFACT_NAME//\//-}" >> $GITHUB_OUTPUT | |
- name: Upload Outputs File | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.create-outputs-file.outputs.ARTIFACT_NAME }} | |
if-no-files-found: error | |
path: ${{ env.OUTPUTS_FILE }} | |
fan-in: | |
needs: [build-base, build-nvidia] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Download Outputs Files | |
uses: actions/download-artifact@v4 | |
id: download-outputs | |
with: | |
pattern: outputs-* | |
merge-multiple: false | |
- name: Upload Outputs Files to Job Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: merged-outputs | |
if-no-file-found: error | |
path: ${{ steps.download-outputs.outputs.download-path }} | |
- name: Check Job Status | |
uses: ./.github/actions/check-jobs-success | |
with: | |
jobs: ${{ toJSON(needs) }} |