Skip to content

Instantly share code, notes, and snippets.

@ramonnteixeira
Created March 20, 2022 14:43
Show Gist options
  • Save ramonnteixeira/752e039741565bde1af07ec9e7d923bf to your computer and use it in GitHub Desktop.
Save ramonnteixeira/752e039741565bde1af07ec9e7d923bf to your computer and use it in GitHub Desktop.
Complete lambda pipeline with bitbucket
image: node:16
clone:
depth: full
definitions:
caches:
sonar: ~/.sonar/cache
services:
docker-6g:
type: docker
memory: 6144
steps:
- step: &step-build
name: Build
caches:
- node
script:
- apt update && apt install zip -y
- yarn
- yarn build
# clean build
- cp -R node_modules/ package.json yarn.lock build/
- cd build
- yarn --production
- rm -rf node_modules/**/**/*.map node_modules/**/*.map node_modules/*/*.ts node_modules/*/typings node_modules/*/test node_modules/*/docs node_modules/@types /node_modules/bson/dist/*.browser.* /node_modules/bson/dist/*.bundle.js
# generate artifact
- zip -r ./my-lambda.zip .
artifacts:
- build/my-lambda.zip
- step: &step-quality
name: Quality
size: 2x
services:
- docker-6g
caches:
- node
- sonar
script:
- yarn lint
- yarn test --all --runInBand --forceExit
- pipe: sonarsource/sonarcloud-scan:1.4.0
- pipe: sonarsource/sonarcloud-quality-gate:0.1.5
- rm -rf .bitbucket
- step: &step-deploy
oidc: true
name: Update Lambda code
script:
- pipe: atlassian/aws-lambda-deploy:1.5.0
variables:
AWS_DEFAULT_REGION: ${AWS_REGION}
AWS_OIDC_ROLE_ARN: ${AWS_ROLE_ARN}
FUNCTION_NAME: ${FUNCTION_NAME}
COMMAND: 'update'
ZIP_FILE: 'build/my-lambda.zip'
FUNCTION_CONFIGURATION: ${FUNCTION_CONFIGURATION}
pipelines:
pull-requests:
feature/*:
- step: *step-build
- step: *step-quality
branches:
homolog:
- step: *step-build
- step: *step-quality
- step:
<<: *step-deploy
deployment: staging
name: Deploy to Homolog
master:
- step: *step-build
- step: *step-quality
- step:
<<: *step-deploy
deployment: production
name: Deploy to Production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment