Skip to content

Commit 0102ba3

Browse files
DesignrKnightroshankshawHarishTeens
authored
Folder restructure and CI/CD (#78)
* Added a restructured directory apollo * fix failing tests * delete unused files after restructure * clean up - remove unused dependecies - edit package.json - gitignore package-lock * delete unused else statement * Edit .gitignore * Combine resolvers component files in apollo directory * Add trigger for deploy branch * GoogleCloudPlatform/github-actions/setup-gcloud has been deprecated. * update docker build from ./sources * Update Dockerfile * Add secrets for .env and admin sdk * Update gcp-deploy.yml * Update gcp-deploy.yml * Update gcp-deploy.yml * Update Dockerfile * Update docker-compose.yml * Update Dockerfile * Update Dockerfile * Delete docs.yml * Update gcp-deploy.yml * Update .dockerignore * Update gcp-deploy.yml * Update gcp-deploy.yml * Update gcp-deploy.yml * Update gcp-deploy.yml * Update index.js * Update gcp-deploy.yml * Update gcp-deploy.yml * Update gcp-deploy.yml Co-authored-by: roshankshaw <[email protected]> Co-authored-by: HarishTeens <[email protected]> Co-authored-by: Harish <[email protected]>
1 parent aedf779 commit 0102ba3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+329
-373
lines changed

.firebaserc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/gcp-deploy.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
name: Build and Deploy to Google Compute Engine
2-
1+
name: Build and Deploy to Server
32
on:
4-
push:
5-
branches:
6-
- development
7-
3+
release:
4+
types:
5+
- created
86
env:
97
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
108
GCE_INSTANCE: server-central-vm
119
GCE_INSTANCE_ZONE: us-central1-a
1210

13-
1411
jobs:
1512
setup-build-publish-deploy:
1613
name: Setup, Build, Publish, and Deploy
@@ -21,7 +18,7 @@ jobs:
2118
uses: actions/checkout@v2
2219

2320
# Setup gcloud CLI
24-
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
21+
- uses: google-github-actions/setup-gcloud@master
2522
with:
2623
version: '290.0.1'
2724
service_account_key: ${{ secrets.GKE_KEY }}
@@ -31,11 +28,20 @@ jobs:
3128
# helper for authentication
3229
- run: |-
3330
gcloud --quiet auth configure-docker
34-
31+
- name: Ignored Files Reveal
32+
run: |-
33+
echo "${{ secrets.ENV_CONFIG }}" > ./sources/env_encoded.txt
34+
- run: |-
35+
echo "${{ secrets.ADMIN_SDK }}" > ./sources/project-elaichi_encoded.txt
36+
- run: |-
37+
cd ./sources && base64 --decode -i env_encoded.txt > .env
38+
- run: |-
39+
cd ./sources && base64 --decode -i project-elaichi_encoded.txt > project-elaichi.json
40+
3541
#Build the Docker image
3642
- name: Build
3743
run: |-
38-
docker build --tag "gcr.io/$PROJECT_ID/$GCE_INSTANCE-image" .
44+
docker build --tag "gcr.io/$PROJECT_ID/$GCE_INSTANCE-image" ./sources
3945
#Push the Docker image to Google Container Registry
4046
- name: Publish
4147
run: |-

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11

22
sources/node_modules
33
sources/db
4-
sources/coverage
4+
project-elaichi.json
5+
package-lock.json
6+
.env
7+
sources/.node_repl_history
8+
sources/.npm/
9+
coverage
510
.vs/
611
.bash_history
712
.bash_logout
@@ -12,11 +17,7 @@ sources/coverage
1217
.gnupg/
1318
.mongorc.js
1419
.mysql_history
15-
sources/.node_repl_history
16-
sources/.npm/
1720
.profile
1821
.ssh/
1922
.viminfo
20-
sources/.env
21-
.gitconfig
22-
project-elaichi.json
23+
.gitconfig

Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

sources/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

sources/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:alpine
2+
3+
WORKDIR /app
4+
5+
COPY package.json /app
6+
7+
# COPY ./project-elaichi.json /app
8+
9+
RUN npm install --production --force
10+
11+
COPY . /app
12+
13+
RUN npm install pm2 -g
14+
15+
CMD ["pm2-runtime","start","index.js","-i","max"]

sources/datasources/accessLevels.js renamed to sources/apollo/accessLevels/accessLevel.datasources.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @format */
22

3-
const AccessLevels = require('../models/accessLevel.js');
4-
const Clubs = require('../models/club.js');
5-
const Users = require('../models/user.js');
3+
const AccessLevels = require('./accessLevel.model.js');
4+
const Clubs = require('../clubs/club.model.js');
5+
const Users = require('../users/user.model.js');
66
const { DataSource } = require('apollo-datasource');
77

88
class AccessLevelAPI extends DataSource {
@@ -58,15 +58,6 @@ class AccessLevelAPI extends DataSource {
5858
await foundUser.save();
5959
await foundClub.save();
6060
return await foundAccessLevel.deleteOne();
61-
}
62-
63-
async deleteAccessLevelFromUser(id){
64-
const foundAccessLevel= await AccessLevels.findById(id);
65-
const userId = foundAccessLevel.user;
66-
const foundUser = await Users.findById(userId);
67-
foundUser.clubAccess = foundUser.clubAccess.filter((access)=>access._id!=id)
68-
await foundUser.save();
69-
return await foundAccessLevel.deleteOne();
7061
}
7162
}
7263

sources/models/accessLevel.js renamed to sources/apollo/accessLevels/accessLevel.model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ var accessLevelSchema = new mongoose.Schema({
1717
timestamps: true
1818
});
1919

20-
module.exports = mongoose.model('AccessLevel', accessLevelSchema);
20+
module.exports = mongoose.models.AccessLevel||mongoose.model('AccessLevel', accessLevelSchema);

0 commit comments

Comments
 (0)