Skip to content

Instantly share code, notes, and snippets.

@sumonst21
Forked from Rodolfombc/gitlab-ci-front-s3.yml
Created August 1, 2023 21:20
Show Gist options
  • Save sumonst21/402852e963c5d69a6c27479efc1afc47 to your computer and use it in GitHub Desktop.
Save sumonst21/402852e963c5d69a6c27479efc1afc47 to your computer and use it in GitHub Desktop.
# Cache node modules - speeds up future builds
cache:
paths:
- node_modules
stages:
- build
- run
variables:
S3_BUCKET_DEV: ${BUCKET_DEV}
S3_BUCKET_PROD: ${BUCKET_PROD}
.yarn_build:
image: node:10
script: |
yarn # Install all dependencies
yarn build:${APP_ENV} # Build command
artifacts:
paths:
- ./build
yarn_dev:
extends: .yarn_build
stage: build
before_script:
- export APP_ENV="dev"
only:
refs:
- develop
yarn_prod:
extends: .yarn_build
stage: build
before_script:
- export APP_ENV="prod"
only:
refs:
- master
.deploy_aws:
image: python:latest
when: manual
script: |
pip install awscli #Install awscli tools
aws s3 sync ./build/ s3://${S3_BUCKET}
deploy_dev:
extends: .deploy_aws
stage: run
dependencies:
- yarn_dev
before_script:
- export S3_BUCKET=${S3_BUCKET_DEV}
only:
refs:
- develop
deploy_prod:
extends: .deploy_aws
stage: run
dependencies:
- yarn_prod
before_script:
- export S3_BUCKET=${S3_BUCKET_PROD}
only:
refs:
- master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment