Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Serverless deploy with state management in S3
name: Continuous deploy
on:
push:
branches: [master]
jobs:
serverless-deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Download `.serverless` state from S3
run: aws s3 sync s3://my-bucket/my-repo-name/env-name/.serverless .serverless --delete
- name: Deploy to AWS
run: npm run deploy
- name: Upload `.serverless` state to S3
run: aws s3 sync .serverless s3://my-bucket/my-repo-name/env-name/.serverless --delete
@Mozart409
Copy link

Mozart409 commented May 27, 2021

Hi, do I need to create my bucket before or will it be created via this name "s3://my-bucket/my-repo-name/env-name" ?

@hadynz
Copy link
Author

hadynz commented May 29, 2021

Hi, do I need to create my bucket before or will it be created via this name "s3://my-bucket/my-repo-name/env-name" ?

Yes, that's right. You will need to ensure that the S3 bucket exists. Either create it manually or look into adding an extra step that does that for you.

@Mozart409
Copy link

Mozart409 commented Jun 2, 2021

thank you 👍

@Talhafayyaz11
Copy link

Talhafayyaz11 commented Aug 27, 2021

@hadynz Hi, can please clarify what is my-repo-name and env-name here. I tried this but while uploading it exits with error code 255.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment