Skip to content

Build

Build #391

Workflow file for this run

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
on:
push:
branches:
- main
paths-ignore:
- README.md
schedule:
- cron: "0 0 * * *"
workflow_dispatch: {}
permissions:
contents: read
packages: write
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
changed:
uses: ./.github/workflows/get-changed.yaml
with:
force: ${{ github.event_name == 'schedule' }}
discover:
name: Discover images to build
runs-on: ubuntu-latest
needs:
- changed
outputs:
matrix: ${{ needs.changed.outputs.imagesToBuildJson }}
count: ${{ needs.changed.outputs.imagesToBuildCount }}
steps:
- name: Echo summary
run: |
echo "Matrix: ${{ needs.changed.outputs.imagesToBuildJson }}"
echo "Count: ${{ needs.changed.outputs.imagesToBuildCount }}"
build:
name: Build images
needs:
- discover
if: ${{ needs.discover.outputs.count != '0' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.discover.outputs.matrix) }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Log in to GHCR
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare APK cache
run: sudo mkdir -p /var/cache/apk
- name: Cache APK packages
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: /var/cache/apk
key: apk-${{ runner.os }}-${{ hashFiles(matrix.config) }}
restore-keys: |
apk-${{ runner.os }}-
- name: Make output dirs (SBOM & image refs)
run: |
mkdir -p /tmp/sbom
mkdir -p /tmp/apko
- name: Build ${{ matrix.name }}
id: apko
uses: chainguard-images/actions/apko-publish@ca94ad0bfa5f31a0e8ba71ff2a7faa1751b9a427 # v1.0.4
with:
config: ${{ matrix.config }}
tag: >-
ghcr.io/${{ github.repository }}/${{ matrix.name }}:latest
${{ matrix.version != 'latest' && format('ghcr.io/{0}/{1}:{2}', github.repository, matrix.name, matrix.version) || '' }}
ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ github.sha }}
sbom-path: /tmp/sbom
image_refs: /tmp/apko/images.txt
- name: Upload SBOMs
if: always() && hashFiles('/tmp/sbom/**') != ''
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: sbom-${{ matrix.name }}-${{ matrix.version }}
path: /tmp/sbom/**
if-no-files-found: warn
compression-level: 6
retention-days: 7
- name: Output digest
shell: bash
run: |-
echo "Published digest(s):"
echo "${{ steps.apko.outputs.digest }}"
- name: Upload image refs
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: image-refs-${{ matrix.name }}-${{ matrix.version }}
path: /tmp/apko/images.txt
if-no-files-found: warn
retention-days: 7