2023-07-16 10:49:16 +01:00
|
|
|
name: Build Docker Image
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- trunk
|
|
|
|
|
|
|
|
jobs:
|
2023-07-19 08:48:24 +01:00
|
|
|
nix-flake-check:
|
|
|
|
runs-on: debian-latest
|
|
|
|
steps:
|
|
|
|
- name: Install prerequisites
|
2023-08-16 09:56:45 +01:00
|
|
|
run: apt update && apt install -y sudo zstd
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Cache Nix store"
|
|
|
|
uses: actions/cache@v3.0.8
|
|
|
|
id: nix-cache
|
|
|
|
with:
|
|
|
|
path: /tmp/nixcache
|
|
|
|
key: "dref-cache-v1"
|
2023-08-16 09:40:07 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: Install Nix
|
|
|
|
uses: https://github.com/cachix/install-nix-action@v22
|
|
|
|
with:
|
|
|
|
extra_nix_config: "experimental-features = nix-command flakes"
|
|
|
|
nix_path: nixpkgs=channel:nixos-23.05
|
2023-07-19 08:48:24 +01:00
|
|
|
- name: Remove access_tokens
|
|
|
|
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Import Nix store cache"
|
|
|
|
if: "steps.nix-cache.outputs.cache-hit == 'true'"
|
|
|
|
run: "nix-store --import < /tmp/nixcache"
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-07-19 08:48:24 +01:00
|
|
|
- name: Check out repository
|
2023-08-15 23:31:33 +01:00
|
|
|
uses: actions/checkout@v3.5.3
|
2023-07-19 08:48:24 +01:00
|
|
|
with:
|
|
|
|
ref: trunk
|
|
|
|
- name: Check codebase
|
|
|
|
run: nix flake check -L
|
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Export Nix store cache"
|
|
|
|
if: "steps.nix-cache.outputs.cache-hit != 'true'"
|
|
|
|
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"
|
|
|
|
|
|
|
|
|
2023-07-19 08:50:58 +01:00
|
|
|
docker-build:
|
|
|
|
needs: nix-flake-check
|
|
|
|
runs-on: debian-latest
|
|
|
|
steps:
|
|
|
|
- name: Install prerequisites
|
2023-08-15 23:31:33 +01:00
|
|
|
run: apt update && apt install -y sudo zstd
|
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Cache Nix store"
|
|
|
|
uses: actions/cache@v3.0.8
|
|
|
|
id: nix-cache
|
|
|
|
with:
|
|
|
|
path: /tmp/nixcache
|
|
|
|
key: "dref-cache-v1"
|
2023-08-16 09:40:07 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: Install Nix
|
|
|
|
uses: https://github.com/cachix/install-nix-action@v22
|
|
|
|
with:
|
|
|
|
extra_nix_config: "experimental-features = nix-command flakes"
|
|
|
|
nix_path: nixpkgs=channel:nixos-23.05
|
2023-07-19 08:50:58 +01:00
|
|
|
- name: Remove access_tokens
|
|
|
|
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Import Nix store cache"
|
|
|
|
if: "steps.nix-cache.outputs.cache-hit == 'true'"
|
|
|
|
run: "nix-store --import < /tmp/nixcache"
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-07-19 08:50:58 +01:00
|
|
|
- name: Check out repository
|
2023-08-15 23:31:33 +01:00
|
|
|
uses: actions/checkout@v3.5.3
|
2023-07-19 08:50:58 +01:00
|
|
|
with:
|
|
|
|
ref: trunk
|
|
|
|
- name: Build image
|
|
|
|
run: nix build .#docker
|
|
|
|
- name: Push image with Skopeo
|
|
|
|
run: |
|
|
|
|
nix-env -i skopeo -f '<nixpkgs>'
|
|
|
|
wget https://raw.githubusercontent.com/containers/skopeo/main/default-policy.json && mkdir /etc/containers && mv default-policy.json /etc/containers/policy.json
|
|
|
|
skopeo copy docker-archive:result docker://icr.gmem.ca/dref:latest
|
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Export Nix store cache"
|
|
|
|
if: "steps.nix-cache.outputs.cache-hit != 'true'"
|
|
|
|
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"
|
|
|
|
|
|
|
|
|
2023-07-16 10:49:16 +01:00
|
|
|
arm-docker-build:
|
2023-07-19 08:48:24 +01:00
|
|
|
needs: nix-flake-check
|
2023-07-17 22:23:23 +01:00
|
|
|
runs-on: debian-latest-arm
|
2023-07-16 10:49:16 +01:00
|
|
|
steps:
|
2023-07-17 22:26:40 +01:00
|
|
|
- name: Install prerequisites
|
2023-08-15 23:31:33 +01:00
|
|
|
run: apt update && apt install -y sudo zstd
|
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Cache Nix store"
|
|
|
|
uses: actions/cache@v3.0.8
|
|
|
|
id: nix-cache
|
|
|
|
with:
|
|
|
|
path: /tmp/nixcache
|
|
|
|
key: "dref-cache-arm-v1"
|
2023-08-16 09:40:07 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: Install Nix
|
|
|
|
uses: https://github.com/cachix/install-nix-action@v22
|
|
|
|
with:
|
|
|
|
extra_nix_config: "experimental-features = nix-command flakes"
|
|
|
|
nix_path: nixpkgs=channel:nixos-23.05
|
2023-07-17 22:48:28 +01:00
|
|
|
- name: Remove access_tokens
|
|
|
|
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-08-16 09:56:45 +01:00
|
|
|
- name: "Import Nix store cache"
|
|
|
|
if: "steps.nix-cache.outputs.cache-hit == 'true'"
|
|
|
|
run: "nix-store --import < /tmp/nixcache"
|
2023-08-15 23:31:33 +01:00
|
|
|
|
2023-07-16 10:49:16 +01:00
|
|
|
- name: Check out repository
|
2023-08-15 23:31:33 +01:00
|
|
|
uses: actions/checkout@v3.5.3
|
2023-07-16 10:49:16 +01:00
|
|
|
with:
|
|
|
|
ref: trunk
|
2023-07-17 22:23:23 +01:00
|
|
|
- name: Build image
|
|
|
|
run: nix build .#docker
|
|
|
|
- name: Push image with Skopeo
|
2023-07-18 07:20:33 +01:00
|
|
|
run: |
|
|
|
|
nix-env -i skopeo -f '<nixpkgs>'
|
2023-07-18 07:44:53 +01:00
|
|
|
wget https://raw.githubusercontent.com/containers/skopeo/main/default-policy.json && mkdir /etc/containers && mv default-policy.json /etc/containers/policy.json
|
2023-07-18 07:35:40 +01:00
|
|
|
skopeo copy docker-archive:result docker://icr.gmem.ca/dref:arm
|
2023-08-16 09:56:45 +01:00
|
|
|
|
|
|
|
- name: "Export Nix store cache"
|
|
|
|
if: "steps.nix-cache.outputs.cache-hit != 'true'"
|
|
|
|
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"
|