Skip to content

Instantly share code, notes, and snippets.

@Rodolfombc
Created July 17, 2020 23:09
Show Gist options
  • Save Rodolfombc/77c22fe6465afcd040cd994cfa8d11e2 to your computer and use it in GitHub Desktop.
Save Rodolfombc/77c22fe6465afcd040cd994cfa8d11e2 to your computer and use it in GitHub Desktop.

Revisions

  1. Rodolfombc created this gist Jul 17, 2020.
    68 changes: 68 additions & 0 deletions gitlab-ci-front-s3.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    # 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