about summary refs log tree commit diff stats
path: root/gitlab-ci.yml
diff options
context:
space:
mode:
authorAlan Pearce2024-04-21 18:46:33 +0200
committerAlan Pearce2024-04-21 20:48:34 +0200
commitbbda985b3aec721a7d972d76780ca981140f6f3c (patch)
tree280bc7475f094a44d6c544327c8a6e8e0fc79f19 /gitlab-ci.yml
parentf334fc8d4caed2663ef3008f43d2f2fc48e3eaa9 (diff)
downloadwebsite-bbda985b3aec721a7d972d76780ca981140f6f3c.tar.lz
website-bbda985b3aec721a7d972d76780ca981140f6f3c.tar.zst
website-bbda985b3aec721a7d972d76780ca981140f6f3c.zip
test gitlab ci
Diffstat (limited to 'gitlab-ci.yml')
-rw-r--r--gitlab-ci.yml44
1 files changed, 26 insertions, 18 deletions
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
index 889c3db..c4af48d 100644
--- a/gitlab-ci.yml
+++ b/gitlab-ci.yml
@@ -1,39 +1,47 @@
-default:
-  image: nixpkgs/nix-flakes
-  before_script:
-    - . <(nix print-dev-env .#ci)
-    - export GOPATH=~/go
+image: nixpkgs/nix-flakes
+
+stages:
+  - check
+  - build
+  - deploy
 
 check:
+  stage: check
   script:
     - nix flake check . --print-build-logs
 
 build:
+  stage: 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
+  before_script:
+    - . <(nix print-dev-env .#ci)
     - 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
+    - just docker-image-fly
+  script:
+    - export DOCKER_TAG="$(date --utc +%Y%m%d%H%M%S)-${CI_COMMIT_SHA}"
+    - just nix-build builder
+    - just docker-image-fly
+    - just docker-inspect result --tmpdir=$TMPDIR
+    - just print-docker-tag
+    - |
+      if fly auth whoami > /dev/null 2>&1
+      then
+        fly auth docker
+        just push-to-registry --tmpdir=$TMPDIR --dest-precompute-digests
+        just print-docker-tag >> build.env
+      fi
   artifacts:
     reports:
       dotenv: build.env
 
 deploy:
+  stage: deploy
   needs:
     - build
   script:
+    - fly auth docker
     - fly deploy --image $FLY_REGISTRY_IMAGE_TAG
   rules:
     - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH