Skip to content

Add docker image builder in nix #62

Add docker image builder in nix

Add docker image builder in nix #62

Workflow file for this run

name: Docker Image CI
on:
push:
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# build-linux:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# outputs:
# linux-image: ${{ steps.meta.outputs.tags }}
# steps:
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-linux
# - name: Build
# uses: docker/build-push-action@v5
# with:
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.meta.outputs.tags }}
# target: linux-build
# cache-from: type=gha
# cache-to: type=gha,mode=max
build:
runs-on: ubuntu-latest
# needs: [build-linux]
permissions:
contents: read
packages: write
strategy:
matrix:
os:
- version: '2.15.1.1189'
target: nix-toltec
# - version: '3.3.2.1666'
# target: qemu-toltec
# - version: '3.5.2.1807'
# target: qemu-toltec
# - version: '3.8.2.1965'
# target: qemu-toltec
# - version: '3.20.0.92'
# target: qemu-toltec
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
suffix=-${{matrix.os.target}}-${{ matrix.os.version }},onlatest=true
- name: Nix Build
run: |
nix build '.#"docker-${{ matrix.os.version }}"'
./result | docker image load
- name: Build
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }}
tags: ${{ steps.meta.outputs.tags }}
target: ${{ matrix.os.target }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
fw_version=${{ matrix.os.version }}
linux_image=${{ needs.build-linux.outputs.linux-image }}