Skip to content

test

test #2

Workflow file for this run

name: Docker React App
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/react-app .
docker push ${{ secrets.DOCKER_USERNAME }}/react-app
- name: SSH and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/react-app
docker stop react-app-container || true
docker rm react-app-container || true
docker run -d -p 80:3000 --name react-app-container ${{ secrets.DOCKER_USERNAME }}/react-app