Skip to content

Merge pull request #10 from Devminjeong-eum/fix/build-error #9

Merge pull request #10 from Devminjeong-eum/fix/build-error

Merge pull request #10 from Devminjeong-eum/fix/build-error #9

Workflow file for this run

name: Devminjeong-eum-FrontEnd-Production
on:
push:
branches:
- main
jobs:
check-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup npm cache
uses: actions/cache@v4
id: npm-cache
with:
path: |
**/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}
- name: Install dependencies
if: ${{ steps.npm-cache.outputs.cache-hit != 'true' }}
run: npm ci
- name: Run Eslint
run: npm run lint
docker-image:
needs: check-lint
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push Docker image
uses: docker/build-push-action@v5
with:
push: true
# platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/devminjeong-eum-backend:latest
deploy:
needs: docker-image
runs-on: ubuntu-latest
steps:
- name: Deploy to AWS EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_SSH_HOST }}
username: ${{ secrets.EC2_SSH_USER }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
IS_RUNNING = $(sudo docker ps -af "status=running" | grep backend)
if [ ! -z "$IS_RUNNING" ]; then
sudo docker stop backend
sudo docker rm backend
fi
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/devminjeong-eum-backend:latest
sudo docker run -p 8080:8080 \
--name backend \
-d ${{ secrets.DOCKER_HUB_USERNAME }}/devminjeong-eum-backend:latest