Skip to content

Commit

Permalink
Merge pull request #11 from HUNG-rushb/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
HUNG-rushb authored Dec 23, 2023
2 parents c16fede + d68d7b8 commit b15d88a
Show file tree
Hide file tree
Showing 161 changed files with 21,733 additions and 21,077 deletions.
18 changes: 18 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": "> 0.25%, not dead"
}
]
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
}
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
DATABASE_URL="mongodb+srv://Hung:[email protected]/Social_Image"
DATABASE_URL="mongodb+srv://Hung:[email protected]/Social_Image"
USER_SIMILAR_WEIGHT={"following":"0.5","interest":"0.3","skill":"0.2"}

8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DATABASE_URL=
IS_LOGGING=1
# Link Public = https://roxqm2ljb8.execute-api.ap-southeast-1.amazonaws.com/
# For tool generatePosts
AWS_ACCESS_KEY=
AWS_SECRET_ACCESS=
AWS_BUCKET_NAME=
APP_ID=
37 changes: 37 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"env": {
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],
"ignorePatterns": [".eslintrc.js", "____Legacy/**","dist/**", "node_modules/**"],
"parserOptions": {
"project": "jsconfig.json",
"sourceType": "module",
"ecmaVersion": "latest"
},
"rules": {
"no-unused-vars": "warn",
"prettier/prettier": [
"warn",
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"endOfLine": "lf",
"singleQuote": true,
"overrides": [
{
"files": "*.json",
"options": {
"tabWidth": 6
}
}
]
}
]
}
}
77 changes: 77 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Deploy to AWS Lambda

on:
push:
branches:
- deploy
- develop
pull_request:
branches:
- deploy
- develop
workflow_dispatch:
branches:
- deploy
- develop

jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_IAM_ROLE_ARN: ${{ secrets.AWS_IAM_ROLE_ARN }}
OWNER_LAYER_ACCOUNT_ID: ${{ secrets.OWNER_LAYER_ACCOUNT_ID }}

steps:
- name: Check if it's a merge commit
run: |
if [ -n "$(git log -1 --merges --pretty=%B)" ]; then
echo "This is a merge commit. Skipping the workflow."
exit 78
fi
- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- 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: ap-southeast-1

- name: Update Code
run: |
npm install
npm run prisma_gen
npm run build
cp src/prisma/ERD.svg dist/prisma/ERD.svg
cp src/prisma/schema.prisma dist/prisma/schema.prisma
cp -r src/prisma_modules dist/prisma_modules
zip -r code.zip dist
aws lambda update-function-code --function-name images-social-backend-service --zip-file fileb://code.zip
- name: Update Node Modules
run: |
mkdir nodejs
cp package.json nodejs/package.json
cd nodejs
npm install --omit=dev
rm package.json package-lock.json
cd ..
zip -r ${GITHUB_WORKSPACE}/package-layer.zip nodejs
aws s3 cp ${GITHUB_WORKSPACE}/package-layer.zip s3://images-social-backend-service-package-layer/package-layer.zip
aws lambda publish-layer-version --layer-name arn:aws:lambda:ap-southeast-1:${OWNER_LAYER_ACCOUNT_ID}:layer:images-social-backend-service-package-layer --content S3Bucket=images-social-backend-service-package-layer,S3Key=package-layer.zip --compatible-runtimes nodejs16.x --compatible-architectures "arm64" "x86_64"
maxLayerVersion=$(aws lambda list-layer-versions --layer-name arn:aws:lambda:ap-southeast-1:${OWNER_LAYER_ACCOUNT_ID}:layer:images-social-backend-service-package-layer --query 'max_by(LayerVersions, &Version).LayerVersionArn' | sed 's/"//g')
aws lambda wait function-updated --function-name images-social-backend-service
aws lambda update-function-configuration --function-name images-social-backend-service --layers $maxLayerVersion
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
prisma_modules
# Logs
logs
*.log
Expand Down Expand Up @@ -101,4 +102,6 @@ dist
# dotenv environment variables file
# .env
# .env.test
# .env.production
# .env.production

# .env
File renamed without changes.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ https://www.section.io/engineering-education/how-to-setup-prisma-client-server-t
Important
https://www.youtube.com/watch?v=rtshCulV2hk
https://byanr.com/aws/deploy-a-node-js-app-on-aws-lightsail/

git pull, enter personal access key
forever list
forever stop 0
forever start src/index.js
Binary file removed ____Legacy/GraphQL-Course-Udemy-main/.DS_Store
Binary file not shown.
3 changes: 0 additions & 3 deletions ____Legacy/GraphQL-Course-Udemy-main/.gitignore

This file was deleted.

Binary file not shown.
70 changes: 0 additions & 70 deletions ____Legacy/GraphQL-Course-Udemy-main/client/README.md

This file was deleted.

44 changes: 0 additions & 44 deletions ____Legacy/GraphQL-Course-Udemy-main/client/package.json

This file was deleted.

Binary file not shown.
43 changes: 0 additions & 43 deletions ____Legacy/GraphQL-Course-Udemy-main/client/public/index.html

This file was deleted.

Binary file not shown.
Binary file not shown.
25 changes: 0 additions & 25 deletions ____Legacy/GraphQL-Course-Udemy-main/client/public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions ____Legacy/GraphQL-Course-Udemy-main/client/public/robots.txt

This file was deleted.

10 changes: 0 additions & 10 deletions ____Legacy/GraphQL-Course-Udemy-main/client/src/App.css

This file was deleted.

Loading

0 comments on commit b15d88a

Please sign in to comment.