about summary refs log tree commit diff stats
path: root/gitlab-ci.yml
blob: 889c3db25e6da1971c752bfb139b7e42a95ff1c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
default:
  image: nixpkgs/nix-flakes
  before_script:
    - . <(nix print-dev-env .#ci)
    - export GOPATH=~/go

check:
  script:
    - nix flake check . --print-build-logs

build:
  needs:
    - check
  variables:
    CI_REGISTRY_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG
    FLY_REGISTRY_IMAGE: registry.fly.io/alanpearce-eu
  script:
    - IMAGE_TAG="$(date --utc +%Y%m%d%H%M%S)-${CI_COMMIT_SHA}"
    - nix build --max-jobs auto .\#server
    - mkdir -p "/etc/containers/"
    - echo '{"default":[{"type":"insecureAcceptAnything"}]}' > /etc/containers/policy.json
    - image-fly
    # - skopeo login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - skopeo --tmpdir=$TMPDIR inspect docker-archive://$(readlink -f result)
    # - skopeo --tmpdir=$TMPDIR copy --dest-precompute-digests docker-archive://$(readlink -f result) docker://$CI_REGISTRY_IMAGE:${IMAGE_TAG}
    - fly auth docker
    - skopeo --tmpdir=$TMPDIR copy --dest-precompute-digests docker-archive://$(readlink -f result) docker://${FLY_REGISTRY_IMAGE}:${IMAGE_TAG}
    - echo "FLY_REGISTRY_IMAGE_TAG=${FLY_REGISTRY_IMAGE}:${IMAGE_TAG}" >> build.env
  artifacts:
    reports:
      dotenv: build.env

deploy:
  needs:
    - build
  script:
    - fly deploy --image $FLY_REGISTRY_IMAGE_TAG
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH