Skip to content

[nix] replace streamLayeredImage to buildImage #31

[nix] replace streamLayeredImage to buildImage

[nix] replace streamLayeredImage to buildImage #31

Workflow file for this run

name: Build Docker Image
# Release on any git tag
on:
pull_request:
push:
tags: ['*']
jobs:
build:
runs-on: [self-hosted, linux, nixos]
strategy:
matrix:
config:
- blastoise
- machamp
- sandslash
outputs:
# I hate copy-paste too, but this is GitHub Action, blame them.
cache-key-blastoise: ${{ steps.build.outputs.cache-key-blastoise }}
cache-key-machamp: ${{ steps.build.outputs.cache-key-machamp }}
cache-key-sandslash: ${{ steps.build.outputs.cache-key-sandslash }}
steps:
- uses: actions/checkout@v4
# with:
# # Checkout the triggered tag name
# ref: ${{ github.ref_name }}
- name: Build docker image file
id: build
run: |
closure="$(nix build -L '.#t1.${{ matrix.config }}.release.docker-image' --no-link --print-out-paths)"
echo "path: $closure"
_dest=/tmp/t1-${{ matrix.config }}-image.tar.gz
cp "$closure" "$_dest"
echo "cache-key-${{ matrix.config }}=$(nix hash file --base32 "$_dest")" > $GITHUB_OUTPUT
nix build -L '.#t1.${{ matrix.config }}.release.doc' --out-link docs
- name: Upload to cache
uses: actions/cache/save@v4
with:
path: /tmp/t1-${{ matrix.config }}-image.tar.gz
key: ${{ steps.build.outputs[format('cache-key-{0}', matrix.config)] }}
- uses: actions/upload-artifact@v4
with:
name: docs-${{ matrix.config }}.pdf
path: |
docs/*.pdf
upload:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
config:
- blastoise
- machamp
- sandslash
steps:
- name: Restore ${{ matrix.config }} from cache
uses: actions/cache/restore@v4
id: cache
with:
path: /tmp/t1-${{ matrix.config }}-image.tar.gz
fail-on-cache-miss: true
key: ${{ needs.build.outputs[format('cache-key-{0}', matrix.config)] }}
- name: Login to GHCR dot IO
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load and push
run: |
docker load < /tmp/t1-${{ matrix.config }}-image.tar.gz
docker tag chipsalliance/t1-${{ matrix.config }}:latest ghcr.io/chipsalliance/t1-${{ matrix.config }}:latest
docker images
#docker push ghcr.io/chipsalliance/t1-${{ matrix.config }}:latest