2
0
mirror of https://github.com/offen/website.git synced 2024-11-24 18:00:27 +01:00

deploy assets to self hosted storage

This commit is contained in:
Frederik Ring 2020-09-27 13:00:14 +02:00
parent 7fb3ce0885
commit 0890b95a86

View File

@ -3,27 +3,26 @@ version: 2.1
jobs: jobs:
deploy: deploy:
docker: docker:
- image: cimg/python:3.7 - image: cimg/base:2020.09
working_directory: ~/offen working_directory: ~/website
steps: steps:
- checkout - checkout
- setup_remote_docker - setup_remote_docker
- aws-cli/install - install_mc
- run: - run:
name: Set build environment depending on branch name: Set build environment depending on branch
command: | command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then if [ "${CIRCLE_BRANCH}" == "master" ]; then
cat >> $BASH_ENV \<< EOF cat >> $BASH_ENV \<< EOF
export SITEURL="https://www.offen.dev" export SITEURL="https://www.offen.dev"
export BUCKET="offen-dev-production" export BUCKET="web-production"
export DISTRIBUTION="E2UP8XHLFOC3QC"
export ROBOTS_FILE="robots.txt.production" export ROBOTS_FILE="robots.txt.production"
export OFFEN_ACCOUNT_ID="5ec8345a-2a45-4eb9-92e5-8d9e5684db58" export OFFEN_ACCOUNT_ID="5ec8345a-2a45-4eb9-92e5-8d9e5684db58"
EOF EOF
else else
cat >> $BASH_ENV \<< EOF cat >> $BASH_ENV \<< EOF
export SITEURL="https://staging.offen.dev" export SITEURL="https://staging.offen.dev"
export BUCKET="offen-dev-staging" export BUCKET="web-staging"
export DISTRIBUTION="E13I20LK8ASYFH" export DISTRIBUTION="E13I20LK8ASYFH"
export ROBOTS_FILE="robots.txt.staging" export ROBOTS_FILE="robots.txt.staging"
export OFFEN_ACCOUNT_ID="8f7ee44a-4cd8-47f2-a77e-8c7c98d46b89" export OFFEN_ACCOUNT_ID="8f7ee44a-4cd8-47f2-a77e-8c7c98d46b89"
@ -33,22 +32,31 @@ jobs:
name: Build name: Build
command: make build command: make build
- run: - run:
name: Deploy to S3 name: Deploy to Storage
command: | command: |
aws s3 sync --delete ./output/. s3://$BUCKET mc mirror --remove --overwrite ./output/ offen/$BUCKET
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION --paths "/*"
workflows: workflows:
version: 2 version: 2
build_deploy: build_deploy:
jobs: jobs:
- deploy: - deploy:
context: AWS context: Storage
filters: filters:
branches: branches:
only: only:
- master - master
- development - development
orbs: commands:
aws-cli: circleci/aws-cli@1.0.0 install_mc:
description: Install MinIO client
steps:
- run:
name: Download client
working_directory: '~'
command: |
curl https://dl.min.io/client/mc/release/linux-amd64/mc -o mc
chmod +x mc
sudo mv mc /usr/local/bin/mc
command -v mc