Skip to content

Build Images

Build Images #413

Workflow file for this run

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 }}
jobs:
build-base:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
fedora-version: [37, 38, 39]
fedora-edition: [base, silverblue]
permissions:
contents: read
packages: write
id-token: write
env:
TAGS: ""
TAGS_CONCAT: ""
IMAGE_NAME: eternal-linux/main/${{ matrix.fedora-edition }}
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: Generate Image Metadata
if: github.event_name != 'pull_request'
shell: bash
run: |
TAGS=()
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.fedora-version }}")
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}")
echo "TAGS=${TAGS[*]}" >> $GITHUB_ENV
echo "TAGS_CONCAT=$(IFS=, ; echo "${TAGS[*]}")" >> $GITHUB_ENV
- name: Generate Image Metadata (Pull Request)
if: github.event_name == 'pull_request'
shell: bash
run: |
TAGS=()
# Add PR number as a tag
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:pr${{ github.event.number }}-${{ matrix.fedora-version }}")
# Add short commit hash with PR number as a tag
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:pr${{ github.event.number }}-$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}")
echo "TAGS=${TAGS[*]}" >> $GITHUB_ENV
echo "TAGS_CONCAT=$(IFS=, ; echo "${TAGS[*]}")" >> $GITHUB_ENV
- name: Login to GHCR
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3
- name: Build Image
id: build
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5
with:
context: .
file: Containerfile
push: true
tags: ${{ env.TAGS_CONCAT }}
build-args: |
FEDORA_VERSION=${{ matrix.fedora-version }}
FEDORA_EDITION=${{ matrix.fedora-edition }}
build-nvidia:
runs-on: ubuntu-latest
needs: build-base
strategy:
fail-fast: false
matrix:
fedora-version: [37, 38, 39]
fedora-edition: [base, silverblue]
nvidia-version: [535]
include:
- nvidia-version: 535
nvidia-is-stable: true
permissions:
contents: read
packages: write
id-token: write
env:
TAGS: ""
TAGS_CONCAT: ""
BASE_TAG: ""
IMAGE_NAME: eternal-linux/main/${{ matrix.fedora-edition }}
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: Generate Image Metadata
if: github.event_name != 'pull_request'
shell: bash
run: |
TAGS=()
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.fedora-version }}-nvidia${{ matrix.nvidia-version }}")
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}-nvidia${{ matrix.nvidia-version }}")
if [[ "${{ matrix.nvidia-is-stable }}" == "true" ]]; then
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.fedora-version }}-nvidia")
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}-nvidia")
fi
echo "TAGS=${TAGS[*]}" >> $GITHUB_ENV
echo "TAGS_CONCAT=$(IFS=, ; echo "${TAGS[*]}")" >> $GITHUB_ENV
echo "BASE_TAG=$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}" >> $GITHUB_ENV
- name: Generate Image Metadata (Pull Request)
if: github.event_name == 'pull_request'
shell: bash
run: |
TAGS=()
# Add PR number as a tag
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:pr${{ github.event.number }}-${{ matrix.fedora-version }}-nvidia${{ matrix.nvidia-version }}")
# Add short commit hash with PR number as a tag
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:pr${{ github.event.number }}-$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}-nvidia${{ matrix.nvidia-version }}")
if [[ "${{ matrix.nvidia-is-stable }}" == "true" ]]; then
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:pr${{ github.event.number }}-${{ matrix.fedora-version }}-nvidia")
TAGS+=("${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:pr${{ github.event.number }}-$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}-nvidia")
fi
echo "TAGS=${TAGS[*]}" >> $GITHUB_ENV
echo "TAGS_CONCAT=$(IFS=, ; echo "${TAGS[*]}")" >> $GITHUB_ENV
echo "BASE_TAG=pr${{ github.event.number }}-$(git rev-parse --short HEAD)-${{ matrix.fedora-version }}" >> $GITHUB_ENV
- name: Login to GHCR
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3
- name: Build Image
id: build
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5
with:
context: .
file: Containerfile.nvidia
push: true
tags: ${{ env.TAGS_CONCAT }}
build-args: |
FEDORA_VERSION=${{ matrix.fedora-version }}
FEDORA_EDITION=${{ matrix.fedora-edition }}
NVIDIA_VERSION=${{ matrix.nvidia-version }}
BASE_TAG=${{ env.BASE_TAG }}
check:
runs-on: ubuntu-latest
needs: [build-base, build-nvidia]
steps:
- name: Exit
shell: bash
run: exit 0