Skip to content

nix-build

nix-build #297

Workflow file for this run

name: Build Container Image
run-name: nix-build
on:
push:
branches: [main]
pull_request:
branches: ['**']
jobs:
Build-Container-Image:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-23.11
- name: Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build manifests
run: nix build .#ociImages
- name: Push to registry
if: ${{ github.ref == 'refs/heads/main' }}
env:
ACTOR: "${{ github.actor }}"
BASE_URL: "ghcr.io/pythoner6"
TOKEN: "${{ secrets.GITHUB_TOKEN }}"
shell: nix develop .#push -c bash {0}
run: |
set -euo pipefail
ACTOR=${ACTOR,,}
source tools/scripts/oci_helpers.sh
crane auth login -u "$ACTOR" --password-stdin <<< "$TOKEN" "ghcr.io"
readarray -t images <<< "$(find result/images -maxdepth 1 -mindepth 1 -type d)"
for image in "${images[@]}"; do
crane push "$image" "$BASE_URL/netserv/$(basename $image):latest"
done
readarray -t charts <<< "$(find result/charts -maxdepth 1 -mindepth 1 -type d)"
for chart in "${charts[@]}"; do
crane push "$chart" "$BASE_URL/charts/$(get_chart_name "$chart"):$(get_chart_version "$chart")"
done
readarray -t apps <<< "$(find result/apps -maxdepth 1 -mindepth 1 -type d)"
for app in "${apps[@]}"; do
if [[ "$app" != "root" ]]; then
crane push "$app" "$BASE_URL/netserv/$(get_chart_name "$app")"
fi
done
crane push "result/apps/root" "$BASE_URL/netserv/$(get_chart_name "result/apps/root")"