Files
fedora-dev/.github/workflows/build.yml

74 lines
1.9 KiB
YAML

name: Build Container Images
on:
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ${{ github.repository }}
jobs:
discover:
runs-on: ubuntu-latest
outputs:
images: ${{ steps.find.outputs.images }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find image directories
id: find
run: |
images=$(find . -name Dockerfile -not -path './.github/*' \
| sed 's|/Dockerfile||; s|^\./||' \
| jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "images=${images}" >> "$GITHUB_OUTPUT"
build:
needs: discover
runs-on: ubuntu-latest
if: ${{ needs.discover.outputs.images != '[]' }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
image: ${{ fromJson(needs.discover.outputs.images) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-${{ matrix.image }}
tags: |
type=raw,value=latest
type=raw,value={{date 'YYYYMMDD'}}
- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.image }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max