Skip to content

Move package and container image builds to Nix #280

Move package and container image builds to Nix

Move package and container image builds to Nix #280

Workflow file for this run

---
name: CI
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
jobs:
formatting-and-quality:
name: Formatting and Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- name: Format
run: nix build -L .#fmt
- name: Clippy
run: nix build -L .#clippy
- name: Test
run: nix build -L --no-sandbox .#test
build:
name: Build
needs:
- formatting-and-quality
runs-on: ubuntu-latest
strategy:
matrix:
package:
- events-to-histogram
- kafka-daq-report
- simulator
- stream-to-file
- trace-archiver
- trace-to-events
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- name: Build
run: nix build -L .#${{ matrix.package }}.package
- name: Build and push container image
if: ${{ github.ref_name == 'main' || github.ref_type == 'tag' }}
run: |
set -x
local_cr="docker-archive://$(nix build .#${{ matrix.package }}.container-image --no-link --print-out-paths)"
remote_cr="docker://ghcr.io/STFC-ICD-Research-and-Design/${{ matrix.package }}"
skopeo copy --dest-creds="dannixon:${{ github.token }}" "$local_cr" "$remote_cr:${{ github.ref_name }}"
skopeo copy --dest-creds="dannixon:${{ github.token }}" "$local_cr" "$remote_cr:${{ github.sha }}"
if [[ "${{ github.ref_type }}" == 'tag' ]]; then
skopeo copy --dest-creds="dannixon:${{ github.token }}" "$local_cr" "$remote_cr:latest"
fi