Skip to content

Instantly share code, notes, and snippets.

@TheBeachMaster
Created January 22, 2022 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheBeachMaster/b5da9b417a3d81409a2a9207dfbe7683 to your computer and use it in GitHub Desktop.
Save TheBeachMaster/b5da9b417a3d81409a2a9207dfbe7683 to your computer and use it in GitHub Desktop.
options:
max-time: 10 # The build should not exceed 10 minutes
docker: true # We'll be using docker later.. Have it enabled
image: node:10.15.0-alpine
pipelines:
default: # (Unfortunately does not work once you enable branches)
- step:
caches:
- node
- docker # https://bitbucket.org/site/master/issues/14144/cache-docker-layers-between-builds
script:
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
# - Maybe install Coala - but requires a python build env maybe we could check
- chmod +x haspython.sh && ./haspython.sh
- npm install netlify-cli snyk -g # Ensure Snyk and Netlify CLI is installed
- snyk auth ${SNYK_TOKEN} -d # Authenticate Snyk
- netlify login # Authenticate Netlify
# For all commit we want to ensure we have vulnerablities tested... And report low|medium|high vulnerabilities
- yarn
pull-requests:
'**': # For any other branch on PR... PR from develop branch
- parallel:
- step:
caches:
- node
name: Test Vulnerabilities
script:
- npm install snyk -g
- snyk auth ${SNYK_TOKEN} -d # Authenticate Snyk
- snyk protect
#- yarn test
- step:
name: Lint Markdown
caches:
- node
script:
- export NODE_ENV=dev
- yarn install --production=false
- yarn run lint-md
branches:
develop:
- parallel:
- step:
caches:
- node
name: Vulnerabilty Test
script:
- npm install snyk -g
- snyk auth ${SNYK_TOKEN} -d # Authenticate Snyk
- snyk protect
# - yarn test
#- snyk monitor
- step:
caches:
- node
- docker
name: Markdown Lint and Copy Over
script:
- export NODE_ENV=dev
- yarn install --production=false
- yarn run lint-md
- yarn run clean
- yarn build
- pipe: atlassian/scp-deploy:0.3.0
variables:
USER: "root"
SERVER: "1.2.3.4"
REMOTE_PATH: "/usr/src/blog/"
LOCAL_PATH: "public"
SSH_KEY: $SOME_KEY # Get this from ENV variables
DEBUG: "true"
EXTRA_ARGS: "-o ServerAliveInterval=10"
- step:
name: Create Image
caches:
- docker # https://bitbucket.org/site/master/issues/14144/cache-docker-layers-between-builds
script: # Remove extra step and copy file to binary using artifacts
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
- docker build -t $DOCKER_USERNAME/$BITBUCKET_REPO_SLUG:$BITBUCKET_BUILD_NUMBER .
- docker push $DOCKER_USERNAME/$BITBUCKET_REPO_SLUG:$BITBUCKET_BUILD_NUMBER
master:
- parallel:
- step:
name: Vulnerabilty Test
caches:
- node
script:
- npm install snyk -g
- snyk auth $SNYK_TOKEN -d # Authenticate Snyk
- snyk protect
#- yarn test
#- snyk monitor
- step:
name: Markdown Lint
caches:
- node
script:
- export NODE_ENV=dev
- yarn install --production=false
- yarn run lint-md
- step:
name: Clean and build
caches:
- node
script:
- export NODE_ENV=production
- yarn install --production=true
- yarn run clean
- yarn build
artifacts: # Share these with the next build stage
- public/**
- step:
name: Deploy to Netlify
trigger: manual
caches:
- node
script:
- npm install netlify-cli -g
- netlify deploy --dir=public --prod
#!/bin/bash
if ! hash python; then
echo "Python is required to run some of these tests"
exit 1
fi
pyver=$(python -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/')
if [[ "$pyver" -lt "27" || "$pyver" -gt "30" ]]
then
echo "This script requires Python 2.7.X installed. Found Python " "$pyver"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment