Last active
February 26, 2020 20:15
-
-
Save avdoshenkov/bba6e53a9dc378f2287aced18b99f1d1 to your computer and use it in GitHub Desktop.
Gitlab CI deploy config for Gatsby JS site and Amazon S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:latest | |
stages: | |
- build | |
- deploy | |
variables: | |
BUCKET_NAME: bucket-name | |
cache: | |
paths: | |
- node_modules/ | |
buildGatsby: | |
stage: build | |
script: | |
- npm install | |
- ./node_modules/.bin/gatsby build | |
artifacts: | |
paths: | |
- public | |
only: | |
- master | |
deploys3: | |
image: "python:3.6.6" # We use python because there is a well-working AWS Sdk | |
stage: deploy | |
dependencies: | |
- buildGatsby | |
before_script: | |
- pip install awscli # Install the SDK | |
script: | |
- aws s3 cp public s3://${BUCKET_NAME} --recursive | |
environment: | |
name: 's3-deploy' | |
url: http://${BUCKET_NAME}.s3.eu-central-1.amazonaws.com # This is the url of the bucket we saved before | |
# source: https://www.alvareznavarro.es/blog/2018/6/how-to-deploy-a-gatsby-website-to-amazon-s3-using-gitlab-ci/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment