Added GH actions + Reouting required for Portfolio reqs
This commit is contained in:
parent
ed5424913f
commit
ca305c0c86
|
@ -0,0 +1,33 @@
|
||||||
|
name: Deploy to Server
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up SSH key
|
||||||
|
uses: actions/ssh-auth@v1
|
||||||
|
with:
|
||||||
|
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Copy code to server
|
||||||
|
run: scp -r -o StrictHostKeyChecking=no -P ${{ secrets.SERVER_SSH_PORT }} . ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/path/to/app/
|
||||||
|
|
||||||
|
- name: Build and Update Container
|
||||||
|
run: ssh -o StrictHostKeyChecking=no -p ${{ secrets.SERVER_SSH_PORT }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "cd /path/to/app && docker build -t my-image ."
|
||||||
|
|
||||||
|
- name: stop and remove previous container
|
||||||
|
run: ssh -o StrictHostKeyChecking=no -p ${{ secrets.SERVER_SSH_PORT }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "export CONTAINER_ID=$(docker ps -q --filter ancestor='my-image:latest')"
|
||||||
|
|
||||||
|
- name: start new container
|
||||||
|
run: ssh -o StrictHostKeyChecking=no -p ${{ secrets.SERVER_SSH_PORT }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "if [ -n "$CONTAINER_ID" ]; then docker stop "$CONTAINER_ID";docker rm "$CONTAINER_ID"; fi"
|
||||||
|
|
||||||
|
- name: start new container
|
||||||
|
run: ssh -o StrictHostKeyChecking=no -p ${{ secrets.SERVER_SSH_PORT }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "docker run -d --name my-container my-image"
|
|
@ -12,8 +12,11 @@ OSU_PASSWORD=
|
||||||
YT_API_KEY=
|
YT_API_KEY=
|
||||||
TWITTER_API_KEY=
|
TWITTER_API_KEY=
|
||||||
TWITTER_API_SECRET=
|
TWITTER_API_SECRET=
|
||||||
|
TWITTER_BEARER_TOKEN=
|
||||||
SPOTIFY_CLIENT_ID=
|
SPOTIFY_CLIENT_ID=
|
||||||
SPOTIFY_CLIENT_SECRET=
|
SPOTIFY_CLIENT_SECRET=
|
||||||
|
SPOTIFY_REDIRECT_URI=
|
||||||
|
SPOTIFY_REFRESH_TOKEN=
|
||||||
S3_CLIENT_ID=
|
S3_CLIENT_ID=
|
||||||
S3_CLIENT_SECRET=
|
S3_CLIENT_SECRET=
|
||||||
S3_BUCKET_NAME=
|
S3_BUCKET_NAME=
|
||||||
|
@ -25,4 +28,5 @@ MAL_CLIENT_ID=
|
||||||
MAL_CLIENT_SECRET=
|
MAL_CLIENT_SECRET=
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
AWS_SECRET_ACCESS_KEY=
|
AWS_SECRET_ACCESS_KEY=
|
||||||
AWS_REGION=
|
AWS_REGION=
|
||||||
|
WAKATIME_API_KEY=
|
|
@ -34,7 +34,7 @@ interface IConfigKeys {
|
||||||
AWS_REGION: string
|
AWS_REGION: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class configStoreFactory {
|
export default class ConfigStoreFactory {
|
||||||
public configStoreType: IconfigStore
|
public configStoreType: IconfigStore
|
||||||
|
|
||||||
constructor(isProd: boolean = false) {
|
constructor(isProd: boolean = false) {
|
||||||
|
|
|
@ -14,6 +14,8 @@ export const app: express.Application = express()
|
||||||
|
|
||||||
hgqlInit()
|
hgqlInit()
|
||||||
|
|
||||||
|
console.log('🚀', '@b68/api', 'v' + pkg.version)
|
||||||
|
|
||||||
const isDev: boolean = process.env.NODE_ENV == 'production'
|
const isDev: boolean = process.env.NODE_ENV == 'production'
|
||||||
console.log(isDev ? '🚀 Production Mode' : '🚀 Development Mode')
|
console.log(isDev ? '🚀 Production Mode' : '🚀 Development Mode')
|
||||||
const configs = new configStore(isDev)
|
const configs = new configStore(isDev)
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently \"npm run dev:express\" \"npm run dev:hasura\"",
|
"dev": "concurrently \"npm run dev:express\" \"npm run dev:hasura\"",
|
||||||
"dev:hasura": "cd hasura && hasura --skip-update-check --envfile ../.env console",
|
"dev:hasura": "cd hasura && hasura --skip-update-check --envfile ../.env console",
|
||||||
"dev:express": "cross-env NODE_ENV=development nodemon -x node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm index.ts --signal SIGKILL",
|
"dev:express": "cross-env NODE_ENV=production nodemon -x node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm index.ts --signal SIGKILL",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"start": "node --es-module-specifier-resolution=node ./dist/index.js",
|
"start": "node --es-module-specifier-resolution=node ./build/index.js",
|
||||||
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,scss,md}\""
|
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,scss,md}\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { makeResponse } from '../../../libs'
|
import OsuController from '../../../controllers/osu.controller'
|
||||||
|
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
const { fetchBestScores, fetchFavBeatmaps, fetchRecentScores, fetchUser } =
|
||||||
|
new OsuController()
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get('/user', fetchUser)
|
||||||
res.send(makeResponse({ message: 'Hello World!' }))
|
router.get('/best', fetchBestScores)
|
||||||
})
|
router.get('/recent', fetchRecentScores)
|
||||||
|
router.get('/fav', fetchFavBeatmaps)
|
||||||
router.all('/err', async (req, res, next) => {
|
|
||||||
try {
|
|
||||||
throw new Error('This is an error')
|
|
||||||
} catch (err) {
|
|
||||||
next(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { makeResponse } from '../../libs'
|
|
||||||
import HashnodeController from '../../controllers/hashnode.controller'
|
import HashnodeController from '../../controllers/hashnode.controller'
|
||||||
|
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import axios from '../helpers/axios_client'
|
import axios from '../helpers/axios_client'
|
||||||
|
import { configKeys } from '../'
|
||||||
|
|
||||||
|
const config = configKeys
|
||||||
|
|
||||||
export default class Github {
|
export default class Github {
|
||||||
public getGithubUser = async () => {
|
public getGithubUser = async () => {
|
||||||
const { data } = await axios.get(`https://api.github.com/user`, {
|
const { data } = await axios.get(`https://api.github.com/user`, {
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${config.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return data
|
return data
|
||||||
|
@ -15,7 +18,7 @@ export default class Github {
|
||||||
`https://api.github.com/users/${username}/repos`,
|
`https://api.github.com/users/${username}/repos`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -27,7 +30,7 @@ export default class Github {
|
||||||
`https://api.github.com/users/${username}/gists`,
|
`https://api.github.com/users/${username}/gists`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -39,7 +42,7 @@ export default class Github {
|
||||||
`https://api.github.com/users/${username}/followers`,
|
`https://api.github.com/users/${username}/followers`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -51,7 +54,7 @@ export default class Github {
|
||||||
`https://api.github.com/users/${username}/following`,
|
`https://api.github.com/users/${username}/following`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -63,7 +66,7 @@ export default class Github {
|
||||||
`https://api.github.com/users/${username}/starred`,
|
`https://api.github.com/users/${username}/starred`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -75,7 +78,7 @@ export default class Github {
|
||||||
`https://api.github.com/users/${username}/events`,
|
`https://api.github.com/users/${username}/events`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue