Skip to content

Commit

Permalink
Merge pull request #38 from Black-Dot-2024/fix/github-actions
Browse files Browse the repository at this point in the history
Fix github actions
  • Loading branch information
DHurtado714-itesm authored Apr 16, 2024
2 parents 0af508e + 42896b2 commit ac722bc
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 94 deletions.
Empty file removed .github/actions/production.yml
Empty file.
45 changes: 0 additions & 45 deletions .github/actions/staging.yml

This file was deleted.

35 changes: 11 additions & 24 deletions .github/actions/develop.yml → .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:

- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
- name: Install PNPM
run: npm install -g pnpm

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: '20.x'
cache: 'pnpm'

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install
run: pnpm install --no-frozen-lockfile

- name: Check for leaked secrets
uses: zricethezav/[email protected]

- name: Prisma Generate
run: pnpm run prisma:generate

- name: Compile
run: pnpm run build

Expand All @@ -47,16 +47,3 @@ jobs:
fi
env:
CI: true

- name: Comment PR with test results
if: github.event_name == 'pull_request'
uses: unsplash/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: |
📝 **Test Results:**
```
${{ steps.run_tests.outputs.result }}
```
check_for_duplicate_messages: true
44 changes: 44 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy to EC2

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Install PNPM
run: npm install -g pnpm

- name: Copy files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
source: '.'
target: '/home/ubuntu/Zeitgeist-Backend'

- name: Deploy application
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
script: |
cd /home/ubuntu/Zeitgeist-Backend
git pull origin main
pnpm install
pnpm run build
pm2 reload "production"
44 changes: 44 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy to EC2

on:
push:
branches:
- staging

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Install PNPM
run: npm install -g pnpm

- name: Copy files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
source: '.'
target: '/home/ubuntu/Staging-Zeitgeist-Backend'

- name: Deploy application
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
script: |
cd /home/ubuntu/Staging-Zeitgeist-Backend
git pull origin staging
pnpm install
pnpm run build
pm2 reload "staging"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"test": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' nyc mocha",
"test": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' nyc mocha 'src/core/app/services/__tests__/*.test.ts'",
"format": "prettier --write .",
"prepare": "husky install",
"prisma:studio": "prisma studio",
Expand Down
34 changes: 18 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"outDir": "./dist",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true
"module": "commonjs",
"target": "es6",
"esModuleInterop": true
},
"include": ["src/**/__tests__/**/*.ts"],
"exclude": ["node_modules", "dist", "./tests"]
"include": ["src/**/*"]
}

0 comments on commit ac722bc

Please sign in to comment.