docker-image-simple #15
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: docker-image-simple | |
on: | |
schedule: | |
- cron: '30 0 * * *' # Scheduled runs every day at 0:30am UTC | |
workflow_dispatch: | |
workflow_call: | |
jobs: | |
"D": # short name because GH will expand with the matrix values | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false # let other jobs try to complete if one fails | |
matrix: | |
include: | |
- os: "ubuntu" | |
release: "jammy" | |
platforms: "linux/amd64,linux/arm64" # Ubuntu doesn't have yet: ,linux/riscv64 | |
cache-from: "type=gha" # all-automatic Github Actions caching | |
cache-to: "type=gha,mode=max" # all-automatic Github Actions caching, max mode | |
- os: "debian" | |
release: "bookworm" | |
platforms: "linux/amd64,linux/arm64" | |
cache-from: "" | |
cache-to: "" | |
- os: "debian" | |
release: "trixie" | |
platforms: "linux/amd64,linux/arm64" | |
cache-from: "" | |
cache-to: "" | |
- os: "debian" | |
release: "sid" | |
platforms: "linux/amd64,linux/arm64" # debian:sid is the only image with riscv64 as of 2024-03-03, but is hasn't all the toolchains yet: ,linux/riscv64 | |
cache-from: "" | |
cache-to: "" | |
- os: "ubuntu" | |
release: "noble" | |
platforms: "linux/amd64,linux/arm64" # Ubuntu doesn't have yet: ,linux/riscv64 | |
cache-from: "" | |
cache-to: "" | |
name: "${{ matrix.release }} (${{ matrix.os }})" | |
env: | |
DOCKERFILE_OS: "${{ matrix.os }}" | |
DOCKERFILE_RELEASE: "${{ matrix.release }}" | |
steps: | |
- name: Checkout build repo | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/armbian-build | |
ref: extensions | |
clean: true # true is default. it *will* delete the hosts /dev if mounted inside. | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} # github username or org | |
password: ${{ secrets.GITHUB_TOKEN }} # github actions builtin token. repo has to have pkg access. | |
- name: Prepare | |
id: prep | |
run: echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Generate Dockerfile for ${{env.DOCKERFILE_OS}}:${{env.DOCKERFILE_RELEASE}} via Armbian helper script | |
id: generate | |
env: | |
DOCKER_ARMBIAN_BASE_IMAGE: "${{env.DOCKERFILE_OS}}:${{env.DOCKERFILE_RELEASE}}" # Use this base image | |
DOCKERFILE_USE_ARMBIAN_IMAGE_AS_BASE: "no" # Do NOT use the Armbian image as base image to speed up; we're creating it here | |
run: | | |
bash ./compile.sh generate-dockerfile | |
- name: Build and push ${{env.DOCKERFILE_OS}}:${{env.DOCKERFILE_RELEASE}} (first try) | |
id: docker_build_first | |
continue-on-error: true | |
timeout-minutes: 40 | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: "${{ matrix.platforms }}" | |
pull: true # Pull new version of base image, always; avoid bit-rot | |
push: true | |
labels: | | |
org.opencontainers.image.title=${{ github.repository }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} | |
cache-from: "${{ matrix.cache-from }}" | |
cache-to: "${{ matrix.cache-to }}" | |
tags: ghcr.io/${{ github.repository_owner }}/armbian-builder:armbian-next-${{env.DOCKERFILE_OS}}-${{env.DOCKERFILE_RELEASE}}-latest | |
- name: sleep a random amount of seconds, up to 60, if build/push failed, before trying again | |
if: steps.docker_build_first.outcome == 'failure' | |
run: | | |
echo "::notice os=${{env.DOCKERFILE_OS}},release=${{env.DOCKERFILE_RELEASE}}::Build/push failed, retrying" | |
sleep $((RANDOM % 60)) | |
- name: Build and push again (second try if first failed) | |
id: docker_build_second | |
if: steps.docker_build_first.outcome == 'failure' | |
continue-on-error: false # let the build break if the two tries fail | |
timeout-minutes: 40 | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: "${{ matrix.platforms }}" | |
pull: false # Don't pull when retrying | |
push: true | |
labels: | | |
org.opencontainers.image.title=${{ github.repository }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} | |
#cache-from: "${{ matrix.cache-from }}" # do NOT reload cache when retrying | |
cache-to: "${{ matrix.cache-to }}" # but do save cache | |
tags: ghcr.io/${{ github.repository }}:armbian-next-${{env.DOCKERFILE_OS}}-${{env.DOCKERFILE_RELEASE}}-latest | |