Skip to content

yugabyte-integration deployment #20

yugabyte-integration deployment

yugabyte-integration deployment #20

Workflow file for this run

name: yugabyte-integration deployment
on:
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 -e DB_URL=${{vars.YUGABYTE_DB_URL}} -e DB_PASSWORD=${{vars.YUGABYTE_PASSWORD}} -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/automation-db:latest
EOF