From 36ab0a4bdbfc88c78a3a998f3f96e159decb2af8 Mon Sep 17 00:00:00 2001
From: "Nandam, Srinivasa Rao (PG/R - Comp Sci & Elec Eng)"
 <s.nandam@surrey.ac.uk>
Date: Thu, 10 Oct 2024 14:50:46 +0000
Subject: [PATCH] Apptainer yml file

---
 apptainer-build-ci.yml | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 apptainer-build-ci.yml

diff --git a/apptainer-build-ci.yml b/apptainer-build-ci.yml
new file mode 100644
index 0000000..9e82c76
--- /dev/null
+++ b/apptainer-build-ci.yml
@@ -0,0 +1,39 @@
+stages:
+  - build
+  - push
+
+Build:
+    tags:
+    - apptainer
+    - build
+    stage: build
+    script:
+      - apptainer build ${CI_PROJECT_NAME}.sif container.def
+
+# Tag the "main" branch as "latest"
+Push latest:
+  variables:
+    # We do not need GitLab to clone the source code.
+    GIT_STRATEGY: none
+  stage: push
+  tags:
+    - apptainer
+    - build
+  # Only "main" should be tagged "latest"
+  rules:
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+  script:
+    - apptainer push ${CI_PROJECT_NAME}.sif oras://container-registry.surrey.ac.uk/shared-containers/${CI_PROJECT_NAME}:latest
+
+Push branch:
+  variables:
+    # We do not need GitLab to clone the source code.
+    GIT_STRATEGY: none
+  stage: push
+  tags:
+    - apptainer
+    - build
+  rules:
+    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
+  script:
+    - apptainer push ${CI_PROJECT_NAME}.sif oras://container-registry.surrey.ac.uk/shared-containers/${CI_PROJECT_NAME}:SHA_$CI_COMMIT_SHORT_SHA
-- 
GitLab