-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (45 loc) · 1.76 KB
/
automation-db.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
name: yugabyte-integration deployment
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build_and_push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image
run: |
docker build --build-arg DB_URL=${{vars.YUGABYTE_DB_URL}} --build-arg DB_PASSWORD=${{vars.YUGABYTE_PASSWORD}} -t ${{ secrets.DOCKER_USERNAME }}/automation-db:latest .
- name: Push Docker Image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/automation-db:latest
deploy:
name: Deploy Docker Image to EC2
needs: build_and_push
runs-on: ubuntu-latest
steps:
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.USER }}@${{ secrets.HOST }} << 'EOF'
# Pull the latest image
docker pull ${{ secrets.DOCKER_USERNAME }}/automation-db:latest
# Stop the current container (if running)
docker stop automation-db || true
docker rm automation-db || true
# Run the new container
# docker run -d --name automation-db -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/automation-db:latest
docker run -d --name automation-db -e DB_URL=${{vars.YUGABYTE_DB_URL}} -e DB_PASSWORD=${{vars.YUGABYTE_PASSWORD}} -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/automation-db:latest
EOF