Skip to content

Commit

Permalink
Deploy commit AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
ProWilliam committed Nov 18, 2024
0 parents commit 449633a
Show file tree
Hide file tree
Showing 55 changed files with 2,867 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AWS Configuration
AWS_ACCESS_KEY_ID=You_account
AWS_SECRET_ACCESS_KEY=Your_secret
AWS_REGION=us-east-1
AWS_ACCOUNT_ID=Your_acount

# DynamoDB Configuration proposed
DYNAMODB_TABLE=MDSDigital-Microservice-items-dev

# Other settings
NODE_ENV=development
PORT=3000

# JWT Secret
JWT_SECRET=your_encryption_word
EXPIRE_IN=1d
31 changes: 31 additions & 0 deletions .eslintrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// .eslintrc.ts
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/no-unused-vars': ['error', {
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_'
}],
'@typescript-eslint/prefer-const': 'error',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy Microservice

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test


deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: |
npm ci
npm install -g serverless
npm install --save-dev serverless-esbuild
- name: Build application
run: |
npm run build
- name: Create env file
run: |
echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> .env.prod
echo "AWS_ACCOUNT_ID=${{ secrets.AWS_ACCOUNT_ID }}" >> .env.prod
echo "NODE_ENV=production" >> .env.prod
echo "DYNAMODB_TABLE=${{ secrets.DYNAMODB_TABLE }}" >> .env.prod
echo "EXPIRE_IN=1d" >> .env.prod
# - name: Remove previous project
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
# AWS_REGION: ${{ secrets.AWS_REGION }}
# DYNAMODB_TABLE: ${{ secrets.DYNAMODB_TABLE }}
# STAGE: prod
# run: sls remove

- name: Deploy to AWS
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
STAGE: prod
run: sls deploy --stage prod --verbose
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# compiled output
/dist
/node_modules
/build
.webpack/
.serverless/

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.*
!.env.example
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
Loading

0 comments on commit 449633a

Please sign in to comment.