Skip to content

Commit

Permalink
added deploy.yaml and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh7i committed Apr 25, 2024
1 parent cf43bf8 commit 6a9df71
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Node.js CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: self-hosted

strategy:
matrix:
node-version: [21.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: systemctl stop nginx
- run: killall node
- run: docker container kill $(docker container ls -q)

- run: cd backend
- run: cd soc_docker_service
- run: docker-compose up -d db redis
- run: sleep 5
- run: docker-compose up -d
- run: sleep 5

- run: cd ..

- name: Create .env with Github Secrets and run script
run: |
touch .env
echo PORT=$ENV_VAR_1 >> .env
echo COMPILER_PORT=$ENV_VAR_2 >> .env
echo DB_HOST=$ENV_VAR_3 >> .env
echo DB_PORT=$ENV_VAR_4 >> .env
echo DB_USER=$ENV_VAR_5 >> .env
echo DB_PASSWORD=$ENV_VAR_6 >> .env
echo DB_NAME=$ENV_VAR_7 >> .env
env:
ENV_VAR_1: ${{ secrets.ENV_VAR_1 }}
ENV_VAR_2: ${{ secrets.ENV_VAR_2 }}
ENV_VAR_3: ${{ secrets.ENV_VAR_3 }}
ENV_VAR_4: ${{ secrets.ENV_VAR_4 }}
ENV_VAR_5: ${{ secrets.ENV_VAR_5 }}
ENV_VAR_6: ${{ secrets.ENV_VAR_6 }}
ENV_VAR_7: ${{ secrets.ENV_VAR_7 }}

- run: npm install
- run: npm start &
- run: sleep 5

- run: cd ../frontend

- name: Create .env with Github Secrets and run script
run: |
touch .env
echo REACT_APP_COMPILATION_URL=$ENV_VAR_11 >> .env
echo REACT_APP_GOOGLE_AUTH=$ENV_VAR_22 >> .env
echo REACT_APP_CODEDB=$ENV_VAR_33 >> .env
echo REACT_APP_AUTH0_DOMAIN=$ENV_VAR_44 >> .env
echo REACT_APP_AUTH0_CLIENT_ID=$ENV_VAR_55 >> .env
echo REACT_APP_CLIENT_URL=$ENV_VAR_66 >> .env
env:
ENV_VAR_11: ${{ secrets.ENV_VAR_11 }}
ENV_VAR_22: ${{ secrets.ENV_VAR_22 }}
ENV_VAR_33: ${{ secrets.ENV_VAR_33 }}
ENV_VAR_44: ${{ secrets.ENV_VAR_44 }}
ENV_VAR_55: ${{ secrets.ENV_VAR_55 }}
ENV_VAR_66: ${{ secrets.ENV_VAR_66 }}

- run: npm install
- run: npm run build

- run: systemctl start nginx

0 comments on commit 6a9df71

Please sign in to comment.