Skip to content

Feature/first user

Feature/first user #24

Workflow file for this run

name: Docker Build and Deploy
on:
pull_request:
types: [closed]
branches: [main]
workflow_dispatch:
jobs:
build-and-deploy:
name: Build, Push and Deploy
runs-on: ubuntu-latest
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
hwangjungseok/react-frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ~/app
docker-compose pull
docker-compose up -d
docker image prune -f