From 621becebdcaa3706bc90d9e70d2971242ed61c39 Mon Sep 17 00:00:00 2001 From: Neshura Date: Sat, 3 Dec 2022 22:25:14 +0100 Subject: [PATCH] CI/CD Version 1 --- .gitlab-ci.yml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..43a69bb --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,69 @@ +# avoids unecessary repulling of node modules +cache: + paths: + - page-test/node_modules/ + +stages: + - lint + #- test + - build + - deploy + +variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + IAMGE_LATES: $CI_REGISTRY_IMAGE:latest + + +.node: + image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node:latest + + +.docker: + image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:20 + + +linter: + image: !reference [.node, image] + stage: lint + before_script: + - cd page-test + - yarn install + script: + - yarn lint + + +build: + image: !reference [.docker, image] + stage: build + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH + CACHING: + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker build $CACHING -t $IMAGE_TAG . + after_script: + - docker save $IMAGE_TAG > docker.tar + artifacts: + expire_in: 30 mins + paths: + - docker.tar + only: + - tags + + +push: + image: !reference [.docker, image] + stage: deploy + needs: + - job: build + artifacts: true + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker load -i docker.tar + script: + - docker tag $IMAGE_TAG $IMAGE_LATEST + - docker push $IMAGE_TAG + - docker push $IMAGE_LATEST + only: + - tags