Skip to content

Instantly share code, notes, and snippets.

@nbcchen
Last active April 9, 2025 04:07
Show Gist options
  • Save nbcchen/37332d9d7dc3cd0db8344a580992b568 to your computer and use it in GitHub Desktop.
Save nbcchen/37332d9d7dc3cd0db8344a580992b568 to your computer and use it in GitHub Desktop.
circleci

Separate Serverless build and deploy.

Steps

Why?

  1. Easier to troubleshoot
  2. There's a known issue with serverless-plugin-typescript building too slowly. The more functions per stack, the slower the build is. If deployment fails because of some IAM permission issues, we can re-run from failed and save some time on the build. The built artifacts are already cached using save_cache, we just need to load them
  3. In the future we can integrate with an artifactory (e.g. JFrog etc)
jobs:
build:
steps:
- run:
command: |
npx serverless package --region us-east-1 --stage $CIRCLE_BRANCH
cp ./.serverless ./artifacts -r
- save_cache:
key: envs-{{ .Revision }}
paths:
- ~/project/node_modules
- ~/project/artifacts
- ~/.envs
deploy:
steps:
- restore_cache:
key: envs-{{ .Revision }}
- run:
command: npx serverless deploy --region us-east-1 --stage $CIRCLE_BRANCH --package ./artifacts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment