From f8871a73e2a97a819d295e4a7e00f0e45e6d3d08 Mon Sep 17 00:00:00 2001 From: s3lph Date: Thu, 2 Aug 2018 21:55:22 +0200 Subject: [PATCH 1/3] GitLab CI: Build an image tagged latest-stable for master. --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9ac4c38..9eac494 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,12 +24,13 @@ build: stage: build script: - docker build -t "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" . - - docker tag "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" registry.gitlab.com/s3lph/matemat:latest-staging + - docker tag "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" "registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || staging)" - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com - docker push "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" - - docker push registry.gitlab.com/s3lph/matemat:latest-staging + - docker push registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || staging) only: - staging + - master staging: stage: staging From 7fc44bab2b4b7b7b92aff3537913faa3f084c895 Mon Sep 17 00:00:00 2001 From: s3lph Date: Thu, 2 Aug 2018 21:59:15 +0200 Subject: [PATCH 2/3] GitLab CI: Fixed a typo. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9eac494..2392411 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,10 +24,10 @@ build: stage: build script: - docker build -t "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" . - - docker tag "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" "registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || staging)" + - docker tag "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" "registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || echo staging)" - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com - docker push "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" - - docker push registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || staging) + - docker push registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || echo staging) only: - staging - master From c933ffd1c7f840886dfa59fdf3b284ba45187f05 Mon Sep 17 00:00:00 2001 From: s3lph Date: Thu, 2 Aug 2018 22:08:47 +0200 Subject: [PATCH 3/3] GitLab CI: Use CI variables instead of git ref-parse. --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2392411..9ea447d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,10 +24,10 @@ build: stage: build script: - docker build -t "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" . - - docker tag "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" "registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || echo staging)" + - docker tag "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" "registry.gitlab.com/s3lph/matemat:latest-$([[ $CI_COMMIT_REF_NAME == "master" ]] && echo stable || echo staging)" - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com - - docker push "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" - - docker push registry.gitlab.com/s3lph/matemat:latest-$([[ $(git symbolic-ref --short HEAD) == "master" ]] && echo stable || echo staging) + - docker push "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" + - docker push registry.gitlab.com/s3lph/matemat:latest-$([[ $CI_COMMIT_REF_NAME == "master" ]] && echo stable || echo staging) only: - staging - master @@ -37,7 +37,7 @@ staging: script: - eval $(ssh-agent -s) - ssh-add - <<<"$STAGING_SSH_PRIVATE_KEY" - - echo "$(git rev-parse HEAD)" | ssh -p 20022 -oStrictHostKeyChecking=no matemat@kernelpanic.lol + - echo "$CI_COMMIT_SHA" | ssh -p 20022 -oStrictHostKeyChecking=no matemat@kernelpanic.lol environment: name: staging url: https://matemat.kernelpanic.lol/