Skip to content

Commit 7e137b0

Browse files
authored
Merge pull request #26 from data-exp-lab/deploy
Deploy to GCP
2 parents a3b2105 + 759734f commit 7e137b0

File tree

3 files changed

+57
-27
lines changed

3 files changed

+57
-27
lines changed

.github/scripts/deploy_deepgit.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# This should be run inside GCP compute engine
3+
4+
# pull deploy branch
5+
cd ~/projects/deepgit
6+
git pull origin deploy
7+
8+
# build and deploy the frontend
9+
cd ~/projects/deepgit
10+
npm install
11+
rm -rf dist
12+
npm run build
13+
touch dist/$(git log -1 --pretty=format:%H)
14+
sudo rm -rf /var/www/deepgit-app/*
15+
sudo cp -rf ~/projects/deepgit/dist/* /var/www/deepgit-app/.
16+
17+
# build and deploy the backend
18+
cd ~/projects/deepgit
19+
cd backend
20+
~/projects/deepgit/.venv/bin/pip install -r requirements.txt
21+
22+
# restart nginx and gunicorn
23+
sudo systemctl restart nginx
24+
sudo systemctl restart gunicorn
25+

.github/workflows/deploy.yml

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

.github/workflows/deploy_gcp.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy to Google Cloud Platform
2+
on:
3+
push:
4+
branches:
5+
- 'deploy'
6+
7+
jobs:
8+
deploy-to-vm:
9+
runs-on: ubuntu-latest # supporting Node 20
10+
permissions:
11+
contents: read
12+
id-token: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- id: 'auth'
18+
uses: google-github-actions/auth@v2
19+
with:
20+
project_id: 'deepgit'
21+
workload_identity_provider: 'projects/417733706772/locations/global/workloadIdentityPools/deployment/providers/github'
22+
23+
- name: 'Deploy'
24+
id: 'compute-ssh'
25+
uses: 'google-github-actions/ssh-compute@v1'
26+
with:
27+
instance_name: 'instance-1'
28+
project_id: 'deepgit'
29+
user: "user"
30+
zone: 'us-central1-f'
31+
ssh_private_key: '${{ secrets.GCP_SSH_PRIVATE_KEY }}'
32+
script: ${{ github.workspace }}/.github/scripts/deploy_deepgit.sh

0 commit comments

Comments
 (0)