about summary refs log tree commit diff stats
path: root/gitlab-ci.yml
diff options
context:
space:
mode:
authorAlan Pearce2024-04-20 18:29:18 +0200
committerAlan Pearce2024-04-20 18:29:18 +0200
commitcc2245f991ca0474e3d4db9fa213be4aa8ccccb7 (patch)
tree81dff8c64a1f1c5c81e6fe8a19e4172d6e77d930 /gitlab-ci.yml
parent3da735c4e72f8de390e5f4f0df63476cac43b6b1 (diff)
downloadwebsite-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.tar.lz
website-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.tar.zst
website-cc2245f991ca0474e3d4db9fa213be4aa8ccccb7.zip
Use gitlab CI
commit 3bca937c9ff91852269a828de0c778db7d1423df
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 01:14:26 2024 +0200

    create gitlab CI configuration

commit ee9eeab17ac88f4020d857dcceb458c66418e2f6
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 16:07:01 2024 +0200

    make helpers for both building and streaming docker images

commit d8340ec8ff3e3f9c51b55e95e27e518330435b7c
Author: Alan Pearce <alan@alanpearce.eu>
Date:   Sat Apr 20 00:20:34 2024 +0200

    use long git hashes for docker tags
Diffstat (limited to 'gitlab-ci.yml')
-rw-r--r--gitlab-ci.yml39
1 files changed, 39 insertions, 0 deletions
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
new file mode 100644
index 0000000..889c3db
--- /dev/null
+++ b/gitlab-ci.yml
@@ -0,0 +1,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