Skip to content

Commit

Permalink
Merge pull request #82 from yeha98555/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
yurychang committed Jun 30, 2023
2 parents 26769a0 + 976ff14 commit 12babe9
Show file tree
Hide file tree
Showing 68 changed files with 3,023 additions and 857 deletions.
7 changes: 7 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ MONGODB_CONNECT_STRING=mongodb+srv://<user>:<password>@rabbit.xb8tvht.mongodb.ne
# production
MONGODB_ENDPOINT=<docdb.amazonaws.com.endpoint>

# redis
REDIS_CONNECT_STRING=redis://127.0.0.1:6379/0

JWT_SECRET=secert

LOG_FILE_DIR=logs
Expand All @@ -23,3 +26,7 @@ NEWEBPAY_HOST=http://localhost:3000
NEWEBPAY_NOTIFY_URL=http://localhost:3000/newebpay/notifiy
NEWEBPAY_RETURN_URL=http://localhost:3000/orders/payment_return # 指定後端解密 url
PAYMENT_RETURN_URL=http://localhost:3000/payment-completed # 指定到前端付款完成頁

# ticket chcking code
TICKET_CHECKIN_KEY=secret
TICKET_CHECKIN_IV=secret
28 changes: 28 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
NODE_ENV=development

PORT=3000

MONGODB_USER=user
MONGODB_PASSWORD=password
MONGODB_DATABASE=test
MONGODB_CONNECT_STRING=mongodb+srv://<user>:<password>@xxxxxxxxxxx/<database>?retryWrites=true&w=majority
MONGODB_ENDPOINT=xxxxxxxxxxxxxxxx.docdb.amazonaws.com

# redis
REDIS_CONNECT_STRING=redis://127.0.0.1:6379/0

JWT_SECRET=secret
LOG_FILE_DIR=logs

# NewebPay
NEWEBPAY_VERSION=1.5
NEWEBPAY_MERCHANT_ID=MSxxxxxxx
NEWEBPAY_HASH_KEY=key
NEWEBPAY_HASH_IV=iv
NEWEBPAY_NOTIFY_URL=https://ticket-haven-dev.onrender.com/orders/payment_notify
NEWEBPAY_RETURN_URL=http://ticket-haven-dev.onrender.com/orders/payment_return
PAYMENT_RETURN_URL=http://ticket-haven-platform.vercel.app/payment-completed

# ticket checkin code
TICKET_CHECKIN_KEY=secret
TICKET_CHECKIN_IV=secret
61 changes: 27 additions & 34 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,31 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3

- name: Install Dependencies
run: yarn install

- name: Run tests
run: yarn test

- name: Build
if: ${{ success() && github.event_name == 'push' }}
run: yarn build

- name: Create deployment package
if: ${{ success() && github.event_name == 'push' }}
run: zip -r deploy.zip . -x ".git/*" -x ".github/*" -x ".vscode/*" -x ".hursky/*" -x "mock/*" -x "__test__/*"

- name: Deploy to AWS
if: ${{ success() && github.event_name == 'push' }}
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ secrets.AWS_APP_NAME }}
environment_name: ${{ secrets.AWS_APP_ENV_NAME }}
existing_bucket_name: ${{ secrets.AWS_BUCKET_NAME }}
version_label: ${{ github.run_id }}
region: ${{ secrets.AWS_REGION }}
deployment_package: deploy.zip
use_existing_version_if_available: true
- name: Checkout Repo
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3

- name: Install Dependencies
run: yarn install

- name: Build
run: yarn build

- name: Create deployment package
run: zip -r deploy.zip . -x ".git/*" -x ".github/*" -x ".vscode/*" -x ".hursky/*" -x "mock/*" -x "__test__/*"

- name: Deploy to AWS
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ secrets.AWS_APP_NAME }}
environment_name: ${{ secrets.AWS_APP_ENV_NAME }}
existing_bucket_name: ${{ secrets.AWS_BUCKET_NAME }}
version_label: ${{ github.run_id }}
region: ${{ secrets.AWS_REGION }}
deployment_package: deploy.zip
use_existing_version_if_available: true
20 changes: 1 addition & 19 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- develop

jobs:
build-and-deploy:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -22,29 +22,11 @@ jobs:
- name: Install Dependencies
run: yarn install

- name: Run tests
run: yarn test

- name: Build
if: ${{ success() && github.event_name == 'push' }}
run: yarn build

- name: Deploy to Render
if: ${{ success() && github.event_name == 'push' }}
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.SERVICE_ID_DEVELOP }} # Can be found as part of the Deploy Hook
api-key: ${{ secrets.RENDER_API_KEY }} # Create your API key in Render Dashboard > Account Settings

- name: Rollback
if: ${{ failure() && github.event_name == 'push' }}
run: |
git reset HEAD~
git push --force
# Post a comment on the pull request
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"body": "The CI job has failed. The last commit has been rolled back."}' \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Technologies used in this project
├── tsconfig.json // TypeScript configuration file
├── .commitlintrc.json // CommitLint configuration file, used for checking the format of Git commit messages
├── .env.sample // .env template file, storing sample environment variables
├── .env.test // .env file for testing
├── .eslintignore // ESLint ignore configuration, specifying files that don't need syntax checking
├── .eslintrc.json // ESLint configuration file, used for setting syntax checking rules
├── .gitignore // Git ignore configuration, specifying files that don't need version control
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
/**
* @type {import('ts-jest').JestConfigWithTsJest}
*/
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');

require('dotenv').config();

module.exports = {
setupFiles: ['dotenv/config'],
coverageDirectory: 'coverage',
preset: 'ts-jest',
testEnvironment: 'node',
Expand Down

0 comments on commit 12babe9

Please sign in to comment.