-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (42 loc) · 1.34 KB
/
deploy.yml
File metadata and controls
49 lines (42 loc) · 1.34 KB
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
name: Deploy to GCP VM
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "0 0 */2 * *"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up gcloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT }}
- name: Start VM (if stopped)
run: |
gcloud compute instances start ${{ secrets.GCP_VM_NAME }} \
--zone=${{ secrets.GCP_VM_ZONE }}
- name: Run commands on VM
run: |
gcloud compute ssh ${{ secrets.GCP_VM_NAME }} \
--zone=${{ secrets.GCP_VM_ZONE }} \
--command "
sudo rm -r exness &&
git clone https://github.com/${{ github.repository }} &&
cd exness &&
docker compose down -v || true &&
docker stop \$(docker ps -aq) || true &&
docker rm \$(docker ps -aq) || true &&
docker volume prune -f || true &&
docker network prune -f || true &&
docker compose build --no-cache &&
docker compose up -d
"