Deploy blog to Amazon S3

This commit is contained in:
Thomas Schwery 2018-11-12 20:03:31 +01:00
parent ed15bc90c9
commit 6061b7a539

View file

@ -1,5 +1,9 @@
image: golang:1.9 image: golang:1.9
variables:
S3_BUCKET_NAME: thomas.inf3.ch
AWS_BUCKET_REGION: us-east-1
gohugo-build: gohugo-build:
script: script:
- git submodule sync --recursive - git submodule sync --recursive
@ -11,13 +15,41 @@ gohugo-build:
paths: paths:
- public - public
gohugo-deploy: deploys3-branch:
image: kyleondy/alpine-rsync image: "python:latest"
stage: deploy stage: deploy
tags: before_script:
- pages - pip install awscli
only:
- master
script: script:
- mkdir -p /volumes/output/thomas - aws s3 cp public s3://${S3_BUCKET_NAME}/${CI_COMMIT_REF_SLUG} --recursive
- rsync -r public/ /volumes/output/thomas environment:
name: ${CI_COMMIT_REF_SLUG}
url: http://${S3_BUCKET_NAME}.s3-website-${AWS_BUCKET_REGION}.amazonaws.com/${CI_COMMIT_REF_SLUG}
on_stop: deploys3-clean
except:
- /^master$/
deploys3-master:
image: "python:latest"
stage: deploy
before_script:
- pip install awscli
script:
- aws s3 cp public s3://${S3_BUCKET_NAME}/ --recursive
environment:
name: ${CI_COMMIT_REF_SLUG}
url: http://${S3_BUCKET_NAME}.s3-website-${AWS_BUCKET_REGION}.amazonaws.com/
only:
- /^master$/
deploys3-clean:
image: "python:latest"
stage: deploy
before_script:
- pip install awscli
script:
- aws s3 rm s3://${S3_BUCKET_NAME}/${CI_COMMIT_REF_SLUG} --recursive
environment:
name: ${CI_COMMIT_REF_SLUG}
action: stop
when: manual