Skip to content

Build and publish images #134

Build and publish images

Build and publish images #134

Workflow file for this run

name: Build and publish images
on:
pull_request:
branches:
- "main"
schedule:
- cron: "0 22 * * *" # Every day at 22:00 (upstream builds at 19:20)
workflow_dispatch:
defaults:
run:
shell: bash
permissions:
contents: read
packages: write
jobs:
check:
name: Pre-flight checks
runs-on: ubuntu-latest
steps:
- name: Ensure upstream build is passing
run: curl -s https://github.com/cgwalters/sync-fedora-ostree-containers/actions/workflows/build.yml/badge.svg | grep -q passing
if: github.event_name == 'schedule'
publish:
name: Build and push image to container registry
runs-on: ubuntu-latest
needs: check
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
variant: [ silverblue ]
version: [ 37, 38, rawhide ]
include:
- version: 38
latest: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup environment
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "CONTAINERFILE=$(find src/ -type f -iname "${{ matrix.variant }}.containerfile")" >> $GITHUB_ENV
- name: Generate tags
id: tag
run: |
tags=()
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
tags+=("${{ matrix.version }}")
if [[ "${{ matrix.version }}" != "rawhide" ]]; then
tags+=("${{ matrix.version }}.${{ env.DATE }}")
fi
if [[ "${{ matrix.latest }}" == "true" ]]; then
tags+=("latest")
fi
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
tags+=("pr-${{ github.event.number }}")
fi
echo "tags=${tags[*]}" >> $GITHUB_OUTPUT
- name: Build image
id: build
uses: redhat-actions/buildah-build@v2
with:
context: src/
containerfiles: ${{ env.CONTAINERFILE }}
build-args: FEDORA_VERSION=${{ matrix.version }}
image: ${{ matrix.variant }}
tags: ${{ steps.tag.outputs.tags }}
oci: true
- name: Push to container registry
id: push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ github.token }}
if: github.ref == 'refs/heads/main' || matrix.version == '38' # We only want the latest version for testing