dref/.gitea/workflows/test-build.yml
Gabriel Simmer c9d65f8de9
Some checks failed
Build Docker Image / nix-flake-check (push) Failing after 10s
Build Docker Image / docker-build (push) Has been skipped
Build Docker Image / arm-docker-build (push) Has been skipped
Install jq
2023-08-16 09:51:58 +01:00

107 lines
3.5 KiB
YAML

name: Build Docker Image
on:
push:
branches:
- trunk
jobs:
nix-flake-check:
runs-on: debian-latest
steps:
- name: Install prerequisites
run: |
apt update && apt install -y sudo zstd jq
echo "USER=$(whoami)" >> $GITHUB_ENV
groupadd -r nixbld
for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done
- name: Install Nix
uses: https://github.com/nixbuild/nix-quick-install-action@v25
- name: Remove access_tokens
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
- name: Restore and cache Nix store
uses: https://github.com/nix-community/cache-nix-action@v1
with:
linux-gc-enabled: true
linux-max-store-size: 536870912
key: cache-${{ matrix.os }}-${{ hashFiles('**/*') }}
restore-keys: |
cache-${{ matrix.os }}
- name: Check out repository
uses: actions/checkout@v3.5.3
with:
ref: trunk
- name: Check codebase
run: nix flake check -L
docker-build:
needs: nix-flake-check
runs-on: debian-latest
steps:
- name: Install prerequisites
run: apt update && apt install -y sudo zstd
- name: Install Nix
uses: https://github.com/nixbuild/nix-quick-install-action@v25
- name: Remove access_tokens
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
- name: Restore and cache Nix store
uses: https://github.com/nix-community/cache-nix-action@v1
with:
linux-gc-enabled: true
linux-max-store-size: 536870912
key: cache-${{ matrix.os }}-${{ hashFiles('**/*') }}
restore-keys: |
cache-${{ matrix.os }}
- name: Check out repository
uses: actions/checkout@v3.5.3
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
arm-docker-build:
needs: nix-flake-check
runs-on: debian-latest-arm
steps:
- name: Install prerequisites
run: apt update && apt install -y sudo zstd
- name: Install Nix
uses: https://github.com/nixbuild/nix-quick-install-action@v25
- name: Remove access_tokens
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
- name: Restore and cache Nix store
uses: https://github.com/nix-community/cache-nix-action@v1
with:
linux-gc-enabled: true
linux-max-store-size: 536870912
key: cache-${{ matrix.os }}-${{ hashFiles('**/*') }}
restore-keys: |
cache-${{ matrix.os }}
- name: Check out repository
uses: actions/checkout@v3.5.3
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:arm