Skip to content

Instantly share code, notes, and snippets.

@TanAlex
Created May 8, 2020 17:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TanAlex/08d1fefedcb38c31f1ff987034f14b3a to your computer and use it in GitHub Desktop.
Save TanAlex/08d1fefedcb38c31f1ff987034f14b3a to your computer and use it in GitHub Desktop.
image: node:10.15.0
test: &test
name: Install and Test
script:
- cd my-tools
- npm install
- npm test
- npm pack
artifacts: # defining the artifacts to be passed to each future step.
# - dist/**
# - folder/files*.txt
- my-tools/my-tools-*.tgz
upload: &upload
name: Upload to S3
image: your-own-aws-deployment-image:latest
script:
- cd my-tools
- echo "$BITBUCKET_BRANCH"
- |
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
echo "AWS credentials not found; skipping deployment...";
elif [ -z "$BITBUCKET_BRANCH" ]; then
echo "Current branch not found; skipping deployment...";
elif [[ "$BITBUCKET_BRANCH" != dev ]] && [[ "$BITBUCKET_BRANCH" != master ]]; then
echo "Current branch does not appear to be a valid environment; skipping deployment...";
else
echo "all good, ready to upload to s3";
for f in `ls my-tools-*.tgz`; do
aws s3 cp "$f" "s3://${MY_TOOLS_BUCKET}/"
done
fi
pipelines:
default:
- step:
<<: *test
branches:
master:
- step:
<<: *test
- step:
<<: *upload
deployment: production
dev:
- step:
<<: *test
- step:
<<: *upload
deployment: dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment