Skip to content

Commit

Permalink
Deploy to staging
Browse files Browse the repository at this point in the history
On push to main
- Automatically apply migrations
- Automatically deploy to staging

closes #276
  • Loading branch information
TangoYankee committed Jun 25, 2024
1 parent 3a2ef38 commit 3d0b882
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 🎭 Staging

on:
push:
branches:
- main

jobs:
migrate:
name: 🧑‍🚀 Migrate
environment:
name: staging-zoning-api
runs-on: ubuntu-latest
env:
DATABASE_USER: ${{secrets.DATABASE_USER}}
DATABASE_PASSWORD: ${{secrets.DATABASE_PASSWORD}}
DATABASE_NAME: ${{secrets.DATABASE_NAME }}
DATABASE_PORT: ${{secrets.DATABASE_PORT}}
DATABASE_HOST: ${{secrets.DATABASE_HOST}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Apply migrations
run: npm run drizzle:migrate
deploy:
name: 🚀 Deploy
environment:
name: staging-zoning-api
url: https://staging-zoning-api.nycplanningdigital.com
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to Heroku
uses: akhileshns/[email protected]
with:
heroku_email: ${{secrets.HEROKU_EMAIL}}
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
team: ${{secrets.HEROKU_TEAM}}
env:
HD_DATABASE_USER: ${{secrets.DATABASE_USER}}
HD_DATABASE_PASSWORD: ${{secrets.DATABASE_PASSWORD}}
HD_DATABASE_NAME: ${{secrets.DATABASE_NAME}}
HD_DATABASE_PORT: ${{secrets.DATABASE_PORT}}
HD_DATABASE_HOST: ${{secrets.DATABASE_HOST}}
HD_STORAGE_URL: ${{secrets.STORAGE_URL}}
HD_NODE_ENV: ${{secrets.NODE_ENV}}
4 changes: 3 additions & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default {
user: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME!,
ssl: process.env.NODE_ENV === "production",
ssl: {
rejectUnauthorized: false,
},
},
} satisfies Config;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"scripts": {
"build": "npm run redoc:build && nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"db/**/*.ts\"",
"start": "nest start",
"dev": "npm run redoc:build && nest start --watch",
"start": "node dist/main",
"start:debug": "npm run redoc:build && nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand Down
3 changes: 3 additions & 0 deletions src/global/providers/db.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const DbProvider: FactoryProvider = {
user: dbConfig.user,
password: dbConfig.password,
database: dbConfig.name,
ssl: {
rejectUnauthorized: false,
},
});

return drizzle(pool, { schema });
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ async function bootstrap() {
app.enableCors();
app.setGlobalPrefix("api");

await app.listen(3000);
await app.listen(process.env.PORT || 3000);
}
bootstrap();

0 comments on commit 3d0b882

Please sign in to comment.