Skip to content

Commit

Permalink
Set up CD/CI for Backend & Types (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuzzNZ authored Apr 1, 2024
2 parents 84e7a15 + 1e748d7 commit 634413e
Show file tree
Hide file tree
Showing 65 changed files with 133 additions and 23 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/backend-dev-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Backend - Deploy (Development Preview)
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_DEV_ID }}
on:
push:
paths:
- 'backend/**'

jobs:
Deploy-Development-Preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@canary
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Javascript Files
run: npm run build
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/backend-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Backend - Deploy (Development)
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_DEV_ID }}
on:
push:
branches:
- dev
paths:
- 'backend/**'

jobs:
Deploy-Development:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@canary
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Javascript Files
run: npm run build
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/backend-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Backend - Deploy (Production)
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_DEV_ID }}
on:
push:
branches:
- main
paths:
- 'backend/**'

jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@canary
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Javascript Files
run: npm run build
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/types-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Types - Publish to npm

on:
push:
branches:
- main
paths:
- 'types/**'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: npm ci
- name: Build package artifacts
run: npm run build
- name: Publish to npm
run: npm publish --access public
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea
*/.env.*
*/.env
!*/.env.example
*/node_modules

### JetBrains ###
Expand Down Expand Up @@ -138,7 +140,7 @@ yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local
*/.env.*

# vercel
.vercel
Expand Down
1 change: 1 addition & 0 deletions aapc-backend/.gitignore → backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
# typescript
*.tsbuildinfo
next-env.d.ts
.vercel
1 change: 1 addition & 0 deletions backend/.vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env.*
File renamed without changes.
18 changes: 5 additions & 13 deletions aapc-backend/package-lock.json → backend/package-lock.json

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

8 changes: 5 additions & 3 deletions aapc-backend/package.json → backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
"private": true,
"description": "The backend of the AAPC website.",
"scripts": {
"dev": "nodemon -x tsx src/index.ts",
"dev": "nodemon -x tsx ./src/index.ts",
"build": "tsc --build",
"start": "tsc --build && node ./dist/index.js"
"start": "node ./dist/index.js",
"deploy:development": "npm run build && vercel build && vercel deploy --prebuilt",
"deploy:production": "npm run build && vercel build --prod && vercel --prod deploy --prebuilt"
},
"dependencies": {
"@aapc/types": "^0.2.0",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"mongodb": "^6.5.0"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/node": "^20.12.2",
"aapc-types": "file:../aapc-types",
"nodemon": "^3.1.0",
"tsx": "^4.7.1",
"typescript": "^5.4.3"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article, User } from "aapc-types";
import { Article, User } from "@aapc/types";
import { Nullable } from "../util/types";

export default interface IRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Article, User } from "aapc-types";
import { Article, User, IArticle } from "@aapc/types";
import IRepository from "../IRepository";
import users from "./data/users.json"
import news from "./data/news.json"
import researches from "./data/researches.json"
import { IArticle } from "aapc-types/src/Article";
import { Nullable } from "../../util/types";

export default class MemoryRepository implements IRepository {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions backend/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"builds": [
{
"src": "dist/index.js",
"use": "@vercel/node"
}
],
"rewrites": [
{
"source": "/(.*)",
"destination": "dist/index.js"
}
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions aapc-types/package.json → types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "aapc-types",
"version": "0.2.0",
"private": true,
"name": "@aapc/types",
"version": "0.2.1",
"description": "Types definitions for the AAPC website.",
"main": "./dist/main.js",
"module": "./dist/main.mjs",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 634413e

Please sign in to comment.