Skip to content
name: Deploy auction-notes-API
# serverless workflow
# https://github.com/serverless/github-action
on:
# which event will execute workflow
push:
branches:
- main
# this as a replacement where u used .env file in ur service
env:
FACEBOOK_CLIENT_ID: ${{ secrets.FACEBOOK_CLIENT_ID }}
FACEBOOK_SECRET_KEY: ${{ secrets.FACEBOOK_SECRET_KEY }}
GOOGLE_APP_ID: ${{ secrets.GOOGLE_APP_ID }}
GOOGLE_SECRET: ${{ secrets.GOOGLE_SECRET }}
ADMIN_EMAIL: ${{secrets.ADMIN_EMAIL }}
jobs:
productionDeployment:
name: production-deployment
runs-on: ubuntu-latest #OS it will run
defaults:
run:
working-directory: ./notes-service
environment:
# to add environment variables
name: Production
# production application endpoint
url: https://test.com
strategy:
matrix:
node-version: [18.x]
steps:
# github actions checkout the code
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# npm ci is npm i but wont change ur packagelock.json
- run: npm ci
working-directory: ./notes-service
- name: Install Plugin and Deploy
uses: serverless/github-action@v3.1
with:
# install serverless plugins
args: -c "cd ./notes-service && serverless plugin install --name serverless-dotenv-plugin && serverless plugin install --name serverless-iam-roles-per-function && serverless plugin install --name serverless-plugin-typescript && serverless plugin install --name serverless-jetpack && serverless plugin install --name serverless-layers && serverless plugin install --name serverless-domain-manager && serverless deploy --stage dev"
# args: -c "npm install --save-dev serverless-iam-roles-per-function && npm install -D serverless-plugin-typescript typescript && serverless deploy --stage production"
entrypoint: /bin/sh
env:
# refer the environment in our github actions configuration
# defined enviroment variable on top it will always get it from environment we have defined
# in our case from production environment
# SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
# or if using AWS credentials directly
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# go to your repository settings page, navigate to the
# "Secrets" tab, and click "New repository secret".
# Give your secret a name and value, then reference it in your workflow using $\{{ secrets.<secret_name> }}.