stages:
  - build
  - push
  - deploy

build:
  stage: build
  image: "nixos/nix:latest"
  tags:
    - kubernetes
  script:
    - nix --extra-experimental-features nix-command --extra-experimental-features flakes build .
    - cp -L result result.tar.gz
  artifacts:
    paths:
      - result.tar.gz
    expire_in: "1 week"

push:
  stage: push
  image: "quay.io/podman/stable"
  tags:
    - kubernetes
  script:
    - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - podman load -i result.tar.gz
    - podman tag "localhost/gregs-homepage:latest" $CI_REGISTRY/greg/homepage/gregs-homepage:latest
    - podman push $CI_REGISTRY/greg/homepage/gregs-homepage:latest

deploy:
  stage: deploy
  tags:
    - deploy
  script:
    - sudo podman pull $CI_REGISTRY/greg/homepage/gregs-homepage:latest
    - sudo systemctl restart podman-homepage
