Add docker image builder in nix #64
This file contains hidden or 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 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 | |
| with: | |
| # Have to use docker as we load an external image. | |
| # Prevents using cache | |
| driver: docker | |
| - uses: actions/checkout@v4 | |
| - uses: cachix/install-nix-action@v31 | |
| - name: Nix Build | |
| run: | | |
| nix build '.#"docker-${{ matrix.os.version }}"' | |
| ./result | docker image load | |
| - 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: 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 | |
| # linux_image=${{ needs.build-linux.outputs.linux-image }} | |
| build-args: | | |
| fw_version=${{ matrix.os.version }} | |