Last active
June 24, 2018 07:50
-
-
Save q7r/60c300988f7bff93dac1e63c932f0bff to your computer and use it in GitHub Desktop.
sample bitbucket-pipelines.yml
This file contains hidden or 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
# On AWS side: | |
# 1. create two custom policies: https://gist.github.com/o1ek/2b32c746ea184f890405cf303fb88057 | |
# 2. create a user with programmatic access and attach the policies. | |
# 3. create S3 buckets gitreponame-master, gitreponame-staging, gitreponame-production, and enable Static website hosting for all. | |
# 4. create three CloudFront Distributions, set S3 buckets as origins and save Distribution IDs, you will use them as AWS_CF_TESTID, AWS_CF_STAGEID, and AWS_CF_PRODUCTIONID | |
# On Bitbucket side: | |
# Go to settings -> Environment variables and add the following values: | |
# AWS_ACCESS_KEY_ID (!click a little lockpad icon near this value!) | |
# AWS_SECRET_ACCESS_KEY (!click a little lockpad icon near this value!) | |
# AWS_DEFAULT_REGION | |
# AWS_CF_TESTID | |
# AWS_CF_STAGEID | |
# AWS_CF_PRODUCTIONID | |
# You may also set slack notifications according the following guide: | |
# https://confluence.atlassian.com/bitbucket/notifications-for-bitbucket-pipelines-857053284.html | |
pipelines: | |
branches: | |
master: | |
- step: | |
caches: | |
- node | |
name: Build master | |
image: node:8-alpine | |
script: | |
- npm install -g @angular/cli | |
- npm install | |
- ng build --prod | |
artifacts: | |
- dist/** | |
- step: | |
name: Auto-deploy to test | |
deployment: test | |
image: atlassian/pipelines-awscli | |
script: | |
- aws s3 sync --delete --acl public-read dist/ s3://$BITBUCKET_REPO_SLUG-$BITBUCKET_BRANCH/ | |
- aws cloudfront create-invalidation --distribution-id $AWS_CF_TESTID --paths /index.html | |
production: | |
- step: | |
caches: | |
- node | |
name: Build project | |
image: node:8-alpine | |
script: | |
- npm install -g @angular/cli | |
- npm install | |
- ng build --prod | |
artifacts: | |
- dist/** | |
- step: | |
name: Auto-deploy to staging | |
deployment: staging | |
image: atlassian/pipelines-awscli | |
script: | |
- aws s3 sync dist/ s3://$BITBUCKET_REPO_SLUG-staging/ -exclude ".*" --delete | |
- aws cloudfront create-invalidation --distribution-id $AWS_CF_STAGINGID --paths /index.html | |
- step: | |
name: Manual deploy to production | |
deployment: production | |
trigger: manual | |
image: atlassian/pipelines-awscli | |
script: | |
- aws s3 sync dist/ s3://$BITBUCKET_REPO_SLUG-$BITBUCKET_BRANCH/ -exclude ".*" --delete | |
- aws cloudfront create-invalidation --distribution-id $AWS_CF_PRODUCTIONID --paths /index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment