Skip to content

Commit

Permalink
ci: added possible working auto deploy :zenon:
Browse files Browse the repository at this point in the history
Took 42 seconds
  • Loading branch information
rokartur committed May 9, 2024
1 parent e409246 commit e0e843a
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 6 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Deployment

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
deploy-frontend:
name: Deploy Frontend
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 20.x ]
architecture: [ x64 ]
cache: [ yarn ]

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
architecture: ${{ matrix.architecture }}
cache: ${{ matrix.cache }}

- name: Install dependencies
run: yarn
working-directory: ./website

- name: Build
run: yarn build
working-directory: ./website
env:
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
OAUTH_REDIRECT_URI: ${{ secrets.OAUTH_REDIRECT_URI }}
DB_URL: ${{ secrets.DB_URL }}

- name: Remove old files from server
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "rm -rf ${{ secrets.SSH_SERVER_FRONTEND_PATH }}*"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

- name: Deploy frontend to server
uses: wlixcc/[email protected]
with:
username: ${{ secrets.SSH_SERVER_USERNAME }}
server: ${{ secrets.SSH_SERVER_NAME }}
port: ${{ secrets.SSH_SERVER_PORT }}
ssh_private_key: ${{ secrets.DEPLOY_KEY }}
local_path: "./website/dist/*"
remote_path: ${{ secrets.SSH_SERVER_FRONTEND_PATH }}

deploy-backend:
name: Deploy Backend
runs-on: ubuntu-latest

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

- name: Remove old files from server
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "rm -rf ${{ secrets.SSH_SERVER_BACKEND_PATH }}*"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

- name: Deploy backend to server
uses: wlixcc/[email protected]
with:
username: ${{ secrets.SSH_SERVER_USERNAME }}
server: ${{ secrets.SSH_SERVER_NAME }}
port: ${{ secrets.SSH_SERVER_PORT }}
ssh_private_key: ${{ secrets.DEPLOY_KEY }}
local_path: "./backend/*"
remote_path: ${{ secrets.SSH_SERVER_BACKEND_PATH }}

- name: Create .env file
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "cd ${{ secrets.SSH_SERVER_BACKEND_PATH }} && echo 'OAUTH_CLIENT_ID="${{ secrets.OAUTH_CLIENT_ID }}"\nOAUTH_CLIENT_SECRET="${{ secrets.OAUTH_CLIENT_SECRET }}"\nOAUTH_REDIRECT_URI="${{ secrets.OAUTH_REDIRECT_URI }}"\nDB_URL="${{ secrets.DB_URL }}"' > .env"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

- name: Run backend
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "cd ${{ secrets.SSH_SERVER_BACKEND_PATH }} && screen -S fitplanconnect-backend -X quit && screen -S fitplanconnect-backend -d -m bun run dev"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
6 changes: 3 additions & 3 deletions backend/src/utils/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dotenv/config'
import { GitHub } from 'arctic'

export const github = new GitHub(
process.env.GITHUB_CLIENT_ID as string,
process.env.GITHUB_CLIENT_SECRET as string,
process.env.OAUTH_CLIENT_ID as string,
process.env.OAUTH_CLIENT_SECRET as string,
{
redirectURI: process.env.GITHUB_REDIRECT_URI as string,
redirectURI: process.env.OAUTH_REDIRECT_URI as string,
},
)
23 changes: 23 additions & 0 deletions docs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"singleAttributePerLine": false,
"htmlWhitespaceSensitivity": "strict",
"vueIndentScriptAndStyle": true,
"proseWrap": "never",
"insertPragma": false,
"printWidth": 120,
"requirePragma": false,
"tabWidth": 2,
"useTabs": true,
"embeddedLanguageFormatting": "off",
"endOfLine": "auto",
"importOrderSeparation": false,
"importOrderCaseInsensitive": true
}
7 changes: 5 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
reactStrictMode: true,
distDir: 'dist',
output: 'export',
})

module.exports = withNextra()
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
"start": "next start",
"prod": "next export"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit e0e843a

Please sign in to comment.