Created
January 13, 2021 16:35
-
-
Save ianrodrigues/318d89edda1085e91df1dd4746df29a5 to your computer and use it in GitHub Desktop.
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
# Here you define the stages of your pipeline. | |
# more info: https://docs.gitlab.com/ee/ci/yaml/#stages | |
stages: | |
- build | |
- deploy | |
# Here you define top-level cache. | |
# In this case, I'm caching the node_modules/ folder, so next you run "yarn install" it won't take too much time. | |
# more info: https://docs.gitlab.com/ee/ci/yaml/#cache | |
cache: | |
key: $CI_COMMIT_REF_SLUG | |
paths: | |
- node_modules/ | |
# Here you define your AWS credentials. I strongly suggest you to use secret variables. | |
# I also set the name of the S3 bucket I want to deploy to. | |
# more info: https://docs.gitlab.com/ee/ci/variables/ | |
variables: | |
AWS_ACCESS_KEY_ID: "" | |
AWS_SECRET_ACCESS_KEY: "" | |
S3_BUCKET_NAME: "" | |
# This is the build job, where we build the app. | |
build-with-yarn: | |
stage: build | |
image: node:lts-alpine # I'm using node lts version (using Alpine) | |
script: | |
- yarn install | |
- yarn build | |
artifacts: # Here I define the artifacts generated by the build and their expiration date. Artifacts are passed between jobs. | |
expires_in: 1 day | |
paths: | |
- dist/ # I defined the directory "dist/" as an artifact. | |
# In this job I get the artifact generated in the previous job and send it to S3 using the AWS CLI. | |
deploy-to-aws: | |
stage: deploy | |
when: manual | |
image: alpine:latest | |
script: | |
- apk add --no-cache curl jq python py-pip | |
- pip install awscli | |
- aws s3 cp dist/ s3://$S3_BUCKET_NAME/ --recursive --include "*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment