Skip to content

Instantly share code, notes, and snippets.

@cedricjacobs
Last active July 14, 2020 08:50
Show Gist options
  • Save cedricjacobs/3dddd9b9ed8910c231ee2789f3221b46 to your computer and use it in GitHub Desktop.
Save cedricjacobs/3dddd9b9ed8910c231ee2789f3221b46 to your computer and use it in GitHub Desktop.
image: node:latest
variables:
AWS_DEFAULT_REGION: eu-west-1
BUCKET_NAME_PRODUCTION: my-s3-bucket-to-host-my-new-website
cache:
paths:
- node_modules/
prepare_environment_production:
stage: build
script:
- yarn install
- yarn run build:production
artifacts:
paths:
- dist/
expire_in: 1 week
only:
- master
deploy_s3_production:
image: 'python:latest'
stage: deploy
dependencies:
- prepare_environment_production
before_script:
- pip install awscli
script:
- export AWS_ACCESS_KEY_ID=$AWS_AID_PRODUCTION
- export AWS_SECRET_ACCESS_KEY=$AWS_SAK_PRODUCTION
- aws s3 sync dist s3://$BUCKET_NAME_PRODUCTION/ --delete
- aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_PRODUCTION_ID --paths /index.html
only:
- master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment