Skip to content

Instantly share code, notes, and snippets.

@selvesandev
Last active May 24, 2023 13:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selvesandev/7f113b9102d1461b1a2ae80a20074d1c to your computer and use it in GitHub Desktop.
Save selvesandev/7f113b9102d1461b1a2ae80a20074d1c to your computer and use it in GitHub Desktop.
Deploy your serverless framework aws lambda function from github actions
name: Deploy to Production
on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# Build job
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup Serverless
run: npm install -g serverless
- name: Install dependencies
run: npm ci
- name: Generate .env file
run: |
echo "${{ secrets.PROD_ENV }}" | base64 --decode > .env
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Deploy
run: sls deploy -c serverless.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment