From 35612e22ecef58bf98464373063dfb4157a30c0b Mon Sep 17 00:00:00 2001 From: jiwon <128473259+zziwonCHOI@users.noreply.github.com> Date: Wed, 1 Oct 2025 01:14:06 +0900 Subject: [PATCH 1/2] Create deploy.yml --- .github/workflows/deploy.yml | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..32dc680 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,57 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Labor-Lawbot CI/CD + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - name: Checkout + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install dependencies + run: npm install + + - name: Create .env.production + run: | + echo "VITE_API_BASE_URL=${{ secrets.VITE_API_BASE_URL }}" >> .env.production + echo "VITE_WS_BASE_URL=${{ secrets.VITE_WS_BASE_URL }}" >> .env.production + + - name: Build React App + run: npm run build + + - name: Deploy to EC2 + uses: appleboy/scp-action@v0.1.4 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + source: "build/*" + target: "/home/ubuntu/lawbot/build" + + - name: Restart Nginx + uses: appleboy/ssh-action@v0.1.6 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + sudo systemctl restart nginx + From 62e4384c799f7d930a4e83ac0bac7a4375827b7e Mon Sep 17 00:00:00 2001 From: jiwon <128473259+zziwonCHOI@users.noreply.github.com> Date: Wed, 1 Oct 2025 01:18:57 +0900 Subject: [PATCH 2/2] Update deploy.yml --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 32dc680..b2b5b1e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,9 +5,9 @@ name: Labor-Lawbot CI/CD on: push: - branches: [ "main" ] + branches: [ "develop" ] pull_request: - branches: [ "main" ] + branches: [ "develop" ] jobs: build-and-deploy: