Initial implementation of gitlab-ci pipeline

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
This commit is contained in:
Collin J. Doering 2017-04-23 22:22:38 -04:00
parent 975f6c42ee
commit 842837dbb3
Signed by: rekahsoft
GPG Key ID: 7B4DEB93212B3022
4 changed files with 75 additions and 3 deletions

43
.gitlab-ci.yml Normal file
View File

@ -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

View File

@ -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 <a name="deploying"></a>
To deploy the site, use the provided `init-env.sh` script. Its usage is as follows:
```
Usage: init_env.sh [create|update] <stack-name> <cf-bucket> <cnames>
init_env.sh init <cf-bucket>
init_env.sh info <stack-name>
init_env.sh [help|--help|-h]
```
First create required initial resources, then create the projects stack, thereby deploying the project.
```
./init-env.sh init <cf-bucket-name>
./init-env.sh create <stack-name> <cf-bucket-name> <cnames>
```
## Issues <a name="issues"></a>
Unfortunately, when trying to install the test-suite dependencies, `webdriver 0.6.1` fails to

View File

@ -107,6 +107,7 @@ Resources:
S3OriginConfig:
OriginAccessIdentity: ''# origin-access-identity/cloudfront/S3Origin
Enabled: true
HttpVersion: http2
Comment: Some comment
DefaultRootObject: index.html
Logging:

View File

@ -1,8 +1,11 @@
#!/bin/bash
TEMPLATE="blog-rekahsoft.yaml"
display_help() {
cat <<EOF
Usage: init_env.sh [create|update] <stack-name> <cf-bucket> <cnames>
init_env.sh init <cf-bucket>
init_env.sh info <stack-name>
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
;;