This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 1.98 KB
/
cd_dev.yaml
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
name: CD - Dev
on: workflow_dispatch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Copy Docker Compose file to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_INSTANCE_HOST }}
username: ${{ secrets.DEV_INSTANCE_USERNAME }}
key: ${{ secrets.DEV_INSTANCE_PEM_KEY }}
source: "./bootstrap/http/compose-dev.yaml"
target: "~/app"
overwrite: true
- name: Install Docker if not present
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_INSTANCE_HOST }}
username: ${{ secrets.DEV_INSTANCE_USERNAME }}
key: ${{ secrets.DEV_INSTANCE_PEM_KEY }}
script: |
if ! command -v docker >/dev/null 2>&1; then
echo "Installing Docker..."
sudo apt-get update
sudo apt-get install -y docker.io
else
echo "Docker already installed."
fi
if ! command -v docker-compose >/dev/null 2>&1; then
echo "Installing Docker Compose..."
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
else
echo "Docker Compose already installed."
fi
- name: Run Docker Compose up
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_INSTANCE_HOST }}
username: ${{ secrets.DEV_INSTANCE_USERNAME }}
key: ${{ secrets.DEV_INSTANCE_PEM_KEY }}
script: |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker-compose -f ~/app/bootstrap/http/compose-dev.yaml pull
sudo docker-compose -f ~/app/bootstrap/http/compose-dev.yaml up -d --force-recreate