-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (45 loc) · 1.54 KB
/
deploy.yaml
File metadata and controls
57 lines (45 loc) · 1.54 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
50
51
52
53
54
55
56
57
name: Deploy to Azure VM
on:
workflow_dispatch:
push:
paths-ignore:
- README.md
- instructions.md
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy application to Azure VM
env:
HOST: 172.177.107.24
USER: azureuser
REPO_URL: https://github.com/yutee/devops-react-fastapi.git
REPO_DIR: devops-react-fastapi
run: |
ssh -o StrictHostKeyChecking=no $USER@$HOST << EOF
echo "Cloning the GitHub repository..."
sudo chmod -R 777 $REPO_DIR/monitoring/data
sudo rm -rf $REPO_DIR
git clone $REPO_URL
echo "Navigating into the repository folder..."
cd $REPO_DIR
echo "Bringing down the current Docker Compose app..."
docker-compose down -v
echo "Setting permissions for Loki data directory..."
sudo mkdir -p monitoring/data/loki/chunks monitoring/data/loki/rules
sudo chown -R 10001:10001 monitoring/data
sudo chmod -R 777 monitoring/data
echo "Creating acme.json..."
touch acme.json
chmod 600 acme.json
echo "Spinning up Docker Compose environment..."
docker-compose up -d
# echo "Testing if the app is running..."
# curl -f http://localhost || { echo "App is not running"; exit 1; }
EOF