forked from devlup-labs/woc
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (87 loc) · 3.88 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: CI/CD
on:
push:
branches:
- main
- soc
pull_request:
branches:
- main
- soc
jobs:
deploy:
runs-on: ubuntu-latest
env:
CI: false
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Run Docker Compose
# run: |
# cp .env.example .env
# docker-compose -f docker-compose.yml up -d
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up gcloud CLI
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
# - name: SSH into the VM
# env:
# CI: false
# run: |
# gcloud compute ssh ${{ secrets.GCP_INSTANCE_NAME}} --zone=${{ secrets.GCP_ZONE }} --command '
# ls -l
# '
# - name: SSH into the VM and clone the repo and install all dependencies
# run: |
# REPO_PATH=~
# repo_name=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
# # SSH into the VM and clone the repo if not exists
# gcloud compute ssh ${{ secrets.GCP_INSTANCE_NAME}} --zone=${{ secrets.GCP_ZONE }} --command "
# REPO_PATH=\$HOME
# if [ ! -d \"\$REPO_PATH/$repo_name\" ]; then
# git clone https://github.com/${{ github.repository }}.git \$REPO_PATH/$repo_name &&
# cd \$REPO_PATH/$repo_name &&
# sudo apt-get update &&
# sudo apt-get install -y nginx &&
# sudo service nginx status &&
# sudo apt update &&
# sudo apt install -y apt-transport-https ca-certificates curl software-properties-common &&
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &&
# sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable\" &&
# apt-cache policy docker-ce &&
# sudo apt install -y docker-ce &&
# sudo systemctl status docker &&
# sudo curl -L \"https://github.com/docker/compose/releases/download/1.29.2/docker-compose-\$(uname -s)-\$(uname -m)\" -o /usr/local/bin/docker-compose &&
# sudo chmod +x /usr/local/bin/docker-compose &&
# docker-compose --version
# else
# echo \"Repository already exists. Skipping clone.\"
# fi
# "
# - name: SSH into the VM and build the Docker image
# env:
# CI: false
# run: |
# REPO_PATH=~
# repo_name=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
# # SSH into the VM and clone the repo
# gcloud compute ssh ${{ secrets.GCP_INSTANCE_NAME}} --zone=${{ secrets.GCP_ZONE }} --command "
# REPO_PATH=\$HOME
# cd \$REPO_PATH/$repo_name &&
# git checkout soc &&
# cp .env.example .env &&
# sudo docker-compose -f docker-compose.yml up -d"
- name: SSH into the VM and edit the nginx file
env:
CI: false
run: |
gcloud compute ssh ${{ secrets.GCP_INSTANCE_NAME}} --zone=${{ secrets.GCP_ZONE }} --command "
cd /etc/nginx/sites-enabled &&
ls -l &&
sudo sh -c grep -E '^\s*try_files \$uri \$uri/ =404;' /etc/nginx/sites-enabled/default | grep -E -v '^\s*#' | sudo sed -i '/^\s*try_files \$uri \$uri\/ =404;/a \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ proxy_pass http:\/\/localhost:8000;' default &&
sudo sh -c grep -E '^\s*try_files \$uri \$uri/ =404;' /etc/nginx/sites-enabled/default | grep -E -v '^\s*#' | sudo sed -i 's/^\(\s*try_files \$uri \$uri\/ =404;\)/# \1/' default
"