From 842837dbb31a226acf6f1e2953d11bd54bb6e547 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Sun, 23 Apr 2017 22:22:38 -0400 Subject: [PATCH] Initial implementation of gitlab-ci pipeline Signed-off-by: Collin J. Doering --- .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 21 +++++++++++++++++++++ blog-rekahsoft.yaml | 1 + init-env.sh | 13 ++++++++++--- 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..3a3b429 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,43 @@ +stages: + - build +# - test + - deploy + +variables: + AWS_DEFAULT_REGION: us-east-1 + +build: + stage: build + image: haskell:8.0.2 + artifacts: + name: "${CI_PROJECT_NAME}__${CI_COMMIT_TAG}__${CI_COMMIT_REF_NAME}__${CI_COMMIT_SHA}" + paths: + - _site/* + script: + - cabal update + - cabal install --enable-tests + - ./site configure + - ./site make + - ./site build + +# test: +# stage: test +# image: node:7.8 +# variables: +# CI: "true" +# script: +# - ./site configure +# - ./site test + +deploy: + stage: deploy + image: cgswong/aws:latest + variables: + S3_BUCKET: blog-rekahsoft-s3bucket-7pigtftqm4v8 + script: + - aws s3 sync _site/ s3://$S3_BUCKET + environment: + name: Rekahsoft Blog + url: http://blog.rekahsoft.com + only: + - master diff --git a/README.md b/README.md index 3a256b4..11a80fe 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # Source Code for **[#! Lambda Slang](http://blog.rekahsoft.ca)** +[![build status](https://gitlab.com/rekahsoft/blog-rekahsoft/badges/master/build.svg)](https://gitlab.com/rekahsoft/blog-rekahsoft/commits/master) + * [Features](#features) * [Tools](#tools) * [License](#license) * [Building](#building) * [Running Tests](#running-tests) +* [Deploying](#deploying) * [Issues](#issues) * [Road Map](#road-map) @@ -66,6 +69,24 @@ instances running on port 4444. Then one must run the following: The `-s` or `--run-selenium` option to `site test` starts a selenium server before running the tests. Another way to run the tests is using cabal directly by running `cabal test`. +## Deploying + +To deploy the site, use the provided `init-env.sh` script. Its usage is as follows: + +``` +Usage: init_env.sh [create|update] + init_env.sh init + init_env.sh info + init_env.sh [help|--help|-h] +``` + +First create required initial resources, then create the projects stack, thereby deploying the project. + +``` +./init-env.sh init +./init-env.sh create +``` + ## Issues Unfortunately, when trying to install the test-suite dependencies, `webdriver 0.6.1` fails to diff --git a/blog-rekahsoft.yaml b/blog-rekahsoft.yaml index 0d8e6cf..ab91b09 100644 --- a/blog-rekahsoft.yaml +++ b/blog-rekahsoft.yaml @@ -107,6 +107,7 @@ Resources: S3OriginConfig: OriginAccessIdentity: ''# origin-access-identity/cloudfront/S3Origin Enabled: true + HttpVersion: http2 Comment: Some comment DefaultRootObject: index.html Logging: diff --git a/init-env.sh b/init-env.sh index ce8eb52..9766f76 100755 --- a/init-env.sh +++ b/init-env.sh @@ -1,8 +1,11 @@ #!/bin/bash +TEMPLATE="blog-rekahsoft.yaml" + display_help() { cat < + init_env.sh init init_env.sh info init_env.sh [help|--help|-h] EOF @@ -26,14 +29,18 @@ BUCKET="$3" CNAMES="$4" case "$OP" in + init) + BUCKET="$2" + aws s3 mb "s3://${BUCKET}" + ;; update|create) # Push cloudformation template to provided bucket - echo aws s3 cp blog-rekahsoft.yaml "s3://${BUCKET}" + aws s3 cp "$TEMPLATE" "s3://${BUCKET}" # Create cloudformation stack - echo aws cloudformation "${OP}-stack" --stack-name "$STACK_NAME" --template-url "https://${BUCKET}.s3.amazonaws.com/blog-rekahsoft.yaml" --parameters ParameterKey=AlternateURLs,ParameterValue=\"${CNAMES}\" --capabilities CAPABILITY_IAM + aws cloudformation "${OP}-stack" --stack-name "$STACK_NAME" --template-url "https://${BUCKET}.s3.amazonaws.com/${TEMPLATE}" --parameters ParameterKey=AlternateURLs,ParameterValue=\"${CNAMES}\" --capabilities CAPABILITY_IAM - echo aws cloudformation wait stack-update-complete --stack-name "$STACK_NAME" + aws cloudformation wait stack-update-complete --stack-name "$STACK_NAME" display_info ;;