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=
|
||||
TWITTER_API_KEY=
|
||||
TWITTER_API_SECRET=
|
||||
TWITTER_BEARER_TOKEN=
|
||||
SPOTIFY_CLIENT_ID=
|
||||
SPOTIFY_CLIENT_SECRET=
|
||||
SPOTIFY_REDIRECT_URI=
|
||||
SPOTIFY_REFRESH_TOKEN=
|
||||
S3_CLIENT_ID=
|
||||
S3_CLIENT_SECRET=
|
||||
S3_BUCKET_NAME=
|
||||
|
@ -25,4 +28,5 @@ MAL_CLIENT_ID=
|
|||
MAL_CLIENT_SECRET=
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_REGION=
|
||||
AWS_REGION=
|
||||
WAKATIME_API_KEY=
|
|
@ -34,7 +34,7 @@ interface IConfigKeys {
|
|||
AWS_REGION: string
|
||||
}
|
||||
|
||||
export default class configStoreFactory {
|
||||
export default class ConfigStoreFactory {
|
||||
public configStoreType: IconfigStore
|
||||
|
||||
constructor(isProd: boolean = false) {
|
||||
|
|
|
@ -14,6 +14,8 @@ export const app: express.Application = express()
|
|||
|
||||
hgqlInit()
|
||||
|
||||
console.log('🚀', '@b68/api', 'v' + pkg.version)
|
||||
|
||||
const isDev: boolean = process.env.NODE_ENV == 'production'
|
||||
console.log(isDev ? '🚀 Production Mode' : '🚀 Development Mode')
|
||||
const configs = new configStore(isDev)
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
"scripts": {
|
||||
"dev": "concurrently \"npm run dev:express\" \"npm run dev:hasura\"",
|
||||
"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",
|
||||
"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}\""
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
import { Router } from 'express'
|
||||
import { makeResponse } from '../../../libs'
|
||||
import OsuController from '../../../controllers/osu.controller'
|
||||
|
||||
const router = Router()
|
||||
const { fetchBestScores, fetchFavBeatmaps, fetchRecentScores, fetchUser } =
|
||||
new OsuController()
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
res.send(makeResponse({ message: 'Hello World!' }))
|
||||
})
|
||||
|
||||
router.all('/err', async (req, res, next) => {
|
||||
try {
|
||||
throw new Error('This is an error')
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
router.get('/user', fetchUser)
|
||||
router.get('/best', fetchBestScores)
|
||||
router.get('/recent', fetchRecentScores)
|
||||
router.get('/fav', fetchFavBeatmaps)
|
||||
|
||||
export default router
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Router } from 'express'
|
||||
import { makeResponse } from '../../libs'
|
||||
import HashnodeController from '../../controllers/hashnode.controller'
|
||||
|
||||
const router = Router()
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import axios from '../helpers/axios_client'
|
||||
import { configKeys } from '../'
|
||||
|
||||
const config = configKeys
|
||||
|
||||
export default class Github {
|
||||
public getGithubUser = async () => {
|
||||
const { data } = await axios.get(`https://api.github.com/user`, {
|
||||
headers: {
|
||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
||||
Authorization: `token ${config.GH_TOKEN}`,
|
||||
},
|
||||
})
|
||||
return data
|
||||
|
@ -15,7 +18,7 @@ export default class Github {
|
|||
`https://api.github.com/users/${username}/repos`,
|
||||
{
|
||||
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`,
|
||||
{
|
||||
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`,
|
||||
{
|
||||
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`,
|
||||
{
|
||||
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`,
|
||||
{
|
||||
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`,
|
||||
{
|
||||
headers: {
|
||||
Autherization: `token ${process.env.GH_TOKEN}`,
|
||||
Authorization: `token ${process.env.GH_TOKEN}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue