Skip to content

Commit

Permalink
prepped for deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin2Shih committed Mar 9, 2024
1 parent 9779922 commit 1111dc7
Show file tree
Hide file tree
Showing 9 changed files with 18,547 additions and 2,142 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/precheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Check

on:
push:
branches:
- 'main'

jobs:
deploy_staging:
name: Build Check
runs-on: ubuntu-latest
environment:
name: production

env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
HOST: 0.0.0.0
ADMIN_JWT_SECRET: ${{ secrets.ADMIN_JWT_SECRET }}
API_TOKEN_SALT: ${{ secrets.API_TOKEN_SALT }}
APP_KEYS: ${{ secrets.APP_KEYS }}
CLOUDINARY_KEY: ${{ secrets.CLOUDINARY_KEY }}
CLOUDINARY_NAME: ${{ secrets.CLOUDINARY_NAME }}
TRANSFER_TOKEN_SALT: ${{ secrets.TRANSFER_TOKEN_SALT }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
TOKEN_TRANSFER_SALT: ${{ secrets.TOKEN_TRANSFER_SALT }}
DATABASE_HOST: ${{ vars.DATABASE_HOST }}
DATABASE_NAME: ${{ vars.DATABASE_NAME }}
DATABASE_PORT: ${{ vars.DATABASE_PORT }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: '20.11.1'

- name: Install dependencies
run: npm install

- name: Build Strapi
run: npm run build

- name: Success
run: echo "🚧 Build successful 🚧"
58 changes: 58 additions & 0 deletions .github/workflows/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Production Deployment

on:
release:
types: [published]

jobs:
deploy_staging:
name: Deploy Production
runs-on: ubuntu-latest
environment:
name: production
url: ${{ vars.ENV_URL }}

env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
HOST: 0.0.0.0
ADMIN_JWT_SECRET: ${{ secrets.ADMIN_JWT_SECRET }}
API_TOKEN_SALT: ${{ secrets.API_TOKEN_SALT }}
APP_KEYS: ${{ secrets.APP_KEYS }}
CLOUDINARY_KEY: ${{ secrets.CLOUDINARY_KEY }}
CLOUDINARY_NAME: ${{ secrets.CLOUDINARY_NAME }}
TRANSFER_TOKEN_SALT: ${{ secrets.TRANSFER_TOKEN_SALT }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
TOKEN_TRANSFER_SALT: ${{ secrets.TOKEN_TRANSFER_SALT }}
DATABASE_HOST: ${{ vars.DATABASE_HOST }}
DATABASE_NAME: ${{ vars.DATABASE_NAME }}
DATABASE_PORT: ${{ vars.DATABASE_PORT }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: '20.11.1'

- name: Install dependencies
run: npm install

- name: Install railway
run: npm install -g @railway/[email protected]

- name: Build Strapi
run: npm run build

- name: Deploy image to Railway
run: >
RAILWAY_TOKEN=${{ secrets.RAILWAY_TOKEN }}
railway up
--service "strapi"
-d
- name: Success
run: echo "🚀 Deploy successful 🚀 "
102 changes: 14 additions & 88 deletions config/database.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,18 @@
const path = require('path');

module.exports = ({ env }) => {
const client = env('DATABASE_CLIENT', 'sqlite');

const connections = {
mysql: {
connection: {
connectionString: env('DATABASE_URL'),
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
mysql2: {
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
postgres: {
connection: {
connectionString: env('DATABASE_URL'),
// strapi-api/config/database.js
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
database: env('DATABASE_NAME', 'bank'),
user: env('DATABASE_USERNAME', 'postgres'),
password: env('DATABASE_PASSWORD', '0000'),
schema: env('DATABASE_SCHEMA', 'public'), // Not required
ssl: {
rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false),
},
schema: env('DATABASE_SCHEMA', 'public'),
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
sqlite: {
connection: {
filename: path.join(
__dirname,
'..',
env('DATABASE_FILENAME', '.tmp/data.db')
),
},
useNullAsDefault: true,
},
};

return {
connection: {
client,
...connections[client],
acquireConnectionTimeout: env.int('DATABASE_CONNECTION_TIMEOUT', 60000),
},
debug: false,
},
};
};
});
19 changes: 18 additions & 1 deletion config/plugins.js
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
module.exports = () => ({});
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: 'cloudinary',
providerOptions: {
cloud_name: env('CLOUDINARY_NAME'),
api_key: env('CLOUDINARY_KEY'),
api_secret: env('CLOUDINARY_SECRET'),
},
actionOptions: {
upload: {},
delete: {},
},
},
},
// ...
});
Loading

0 comments on commit 1111dc7

Please sign in to comment.