Skip to content

Commit 259f6a1

Browse files
committed
Configure GitHub actions workflow
1 parent 8d541fd commit 259f6a1

File tree

3 files changed

+39
-32
lines changed

3 files changed

+39
-32
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the main branch
84
push:
9-
branches: [ main ]
5+
branches: [main]
106

11-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
127
jobs:
13-
# This workflow contains a single job called "build"
14-
deploy:
15-
# The type of runner that the job will run on
8+
test:
169
runs-on: ubuntu-latest
17-
18-
# Steps represent a sequence of tasks that will be executed as part of the job
10+
services:
11+
postgres:
12+
image: postgres
13+
env:
14+
POSTGRES_USER: postgres
15+
POSTGRES_PASSWORD: postgres
16+
options: >-
17+
--health-cmd pg_isready
18+
--health-interval 10s
19+
--health-timeout 5s
20+
--health-retries 5
21+
ports:
22+
# Maps TCP port 5432 on service container to the host
23+
- 5432:5432
24+
env:
25+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/proto
26+
JWT_TOKEN_SECRET: ${{ secrets.JWT_TOKEN_SECRET }}
27+
CLIENT_ID_GITHUB: ${{ secrets.CLIENT_ID_GITHUB }}
28+
CLIENT_SECRET_GITHUB: ${{ secrets.CLIENT_SECRET_GITHUB }}
29+
REDIRECT_URI_GITHUB: ${{ secrets.REDIRECT_URI_GITHUB }}
30+
FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
31+
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
32+
JUDGE_API_URL: ${{ secrets.JUDGE_API_URL }}
33+
NODE_ENV: ${{ secrets.NODE_ENV }}
1934
steps:
20-
- name: Extract branch name
21-
shell: bash
22-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
23-
id: extract_branch
24-
25-
- name: SSH Remote Commands
26-
uses: appleboy/[email protected]
35+
- uses: actions/checkout@v2
36+
- uses: actions/setup-node@v1
2737
with:
28-
host: ${{ secrets.HOST }}
29-
username: ${{ secrets.USERNAME }}
30-
password: ${{ secrets.PASSWORD }}
31-
script: |
32-
cd proto
33-
git checkout ${{ steps.extract_branch.outputs.branch }}
34-
git pull
35-
yarn run build
36-
yarn run start
38+
node-version: "16.13"
39+
- run: yarn run install
40+
- run: yarn run setup
41+
- run: cd backend && (yarn run test:dev & yarn run test)

backend/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const typeDefs = require("./graphql/typeDefs/typeDefs");
1212
const resolvers = require("./graphql/resolvers");
1313

1414
const FRONTEND_URL = process.env.FRONTEND_URL as string;
15-
const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID as string;
16-
const GITHUB_CLIENT_SECRET = process.env.GITHUB_CLIENT_SECRET as string;
17-
const GITHUB_REDIRECT_URI = process.env.GITHUB_REDIRECT_URI as string;
15+
const GITHUB_CLIENT_ID = process.env.CLIENT_ID_GITHUB as string;
16+
const GITHUB_CLIENT_SECRET = process.env.CLIENT_SECRET_GITHUB as string;
17+
const GITHUB_REDIRECT_URI = process.env.REDIRECT_URI_GITHUB as string;
1818
const SESSION_SECRET = process.env.SESSION_SECRET as string;
1919

2020
let sessionConfig: any = {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"author": "zaini <[email protected]>",
66
"license": "MIT",
77
"scripts": {
8-
"build": "(nvm use 16.13) && (cd backend && yarn install && yarn run build) & (cd frontend && yarn install && yarn run build)",
8+
"install": "(cd backend && yarn install --frozen-lockfile) && (cd frontend && yarn install --frozen-lockfile)",
9+
"setup": "(cd backend && yarn run judge) && (cd backend && yarn run test:db:setup) && (cd backend && yarn run test:db:seed)",
10+
"build": "(cd backend && yarn run build) & (cd frontend yarn run build)",
911
"start": "(pm2 delete all || true) && ((cd frontend && pm2 start npm --name \"proto_frontend\" -- start) & (cd backend && pm2 start npm --name \"proto_backend\" -- start))"
1012
}
11-
}
13+
}

0 commit comments

Comments
 (0)