From ec476e9fbdca2805e0680a72b63a07ae6958d77b Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 8 Jan 2021 18:08:09 +0100 Subject: CI: add initial .gitlab-ci.yml for deployment We want the CI to deploy to our staging site[0] upon every commit to the main branch, and to our produciton site[1] only from new tags in the main branch. [0] https://dream-stage.public.cat [1] https://dream.public.cat --- .gitlab-ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..f171d6d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +image: + name: alpine@sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436 + +.setup: &setup + - apk -U add curl + +staging: + extends: .setup + script: + - curl "https://$authuser:$authpass@dream.public.cat/api/deploy/stage" + +production: + extends: .setup + script: + - curl "https://$authuser:$authpass@dream.public.cat/api/deploy/production/$CI_COMMIT_REF_NAME" + only: + - tags + except: + - branches -- cgit v1.2.3 From 230385fc7b05c7c09ef20d8bbe4e417e336480e9 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 8 Jan 2021 18:14:13 +0100 Subject: CI: fix syntax in .gitlab-ci.yml The syntax for the "before_script" template was missing an important key. --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f171d6d..36b2420 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,9 @@ image: name: alpine@sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436 -.setup: &setup - - apk -U add curl +.setup: + before_script: + - apk -U add curl staging: extends: .setup -- cgit v1.2.3 From cb4d0e13ac3238a8cf9523958eb74a7a6bb70561 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 8 Jan 2021 18:19:19 +0100 Subject: CI: make curl more verbose We want to specify the POST, as well as include the protocol response headers in the output. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36b2420..a73a73c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,12 +8,12 @@ image: staging: extends: .setup script: - - curl "https://$authuser:$authpass@dream.public.cat/api/deploy/stage" + - curl -i -X POST "https://$authuser:$authpass@dream.public.cat/api/deploy/stage" production: extends: .setup script: - - curl "https://$authuser:$authpass@dream.public.cat/api/deploy/production/$CI_COMMIT_REF_NAME" + - curl -i -X POST "https://$authuser:$authpass@dream.public.cat/api/deploy/production/$CI_COMMIT_REF_NAME" only: - tags except: -- cgit v1.2.3 From 524db9c3949bf6648c1881ebd1e5bea5c320e856 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 8 Jan 2021 18:31:10 +0100 Subject: CI: use a docker image which already contains curl It's a waste of resources to download/install curl for each job. Let's use the "official" curl image instead. --- .gitlab-ci.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a73a73c..d426a36 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,11 @@ image: - name: alpine@sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436 - -.setup: - before_script: - - apk -U add curl + name: curlimages/curl@sha256:a3e534fced74aeea171c4b59082f265d66914d09a71062739e5c871ed108a46e staging: - extends: .setup script: - curl -i -X POST "https://$authuser:$authpass@dream.public.cat/api/deploy/stage" production: - extends: .setup script: - curl -i -X POST "https://$authuser:$authpass@dream.public.cat/api/deploy/production/$CI_COMMIT_REF_NAME" only: -- cgit v1.2.3