Skip to content

Commit

Permalink
add git action for gcloud CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
JangAyeon committed Apr 14, 2024
1 parent 7547c6f commit c0df40a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.env
.env.dev
.env.prod
.env.dev
/node_modules
npm-debug-log
20 changes: 20 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Deploy Discord-Study

on:
push:
branches:
- "main"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: code checkout
uses: actions/checkout@v2

- name: install gcloud CLI
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{secrets.GOOGLE_PROJECT}}
service_account_key: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
export_default_credentials: true
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.env
.env.dev
.env.prod
/node_modules
Dockerfile
/node_modules
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## set base image
FROM node:20-alpine


## set working directory
WORKDIR /usr/src/app

## COPY necessory files
COPY package*.json ./

## Install necessory packages
RUN npm ci

COPY . .


CMD ["npm", "run","start"]
2 changes: 1 addition & 1 deletion client.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ client.on("voiceStateUpdate", (oldState, newState) => {
});

client.login(process.env.DISCORD_TOKEN).catch((error) => {
console.log(err);
console.log(error);
process.exit(1);
});

Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"
services:
discord-study-v2:
image: discord-study-v2
container_name: discord-study-v2
build:
context: .
dockerfile: Dockerfile
env_file:
- .env
2 changes: 1 addition & 1 deletion duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function initUserState(userInfo, state) {
enter: new Date(),
...state
});
// console.log(`${id}:${name} joined`);
console.log(`${id}:${name} joined`);
// console.log(userState.get(id))


Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
const dotenv = require("dotenv");

let path;

switch (process.env.NODE_ENV) {
case "dev":
path = `${__dirname}/.env.dev`;
break;
case "prod":
path = `${__dirname}/.env.prod`;

break;
default:
path = `${__dirname}/.env`;
}

console.log(path, `${process.env.NODE_ENV}`);
console.log(path, `${process.env.NODE_ENV} ${process.env.DISCORD_TOKEN}`);
dotenv.config({ path: path }); // path 설정

const client = require("./client");

0 comments on commit c0df40a

Please sign in to comment.