Skip to content

Commit

Permalink
Reflect the changes so far in deployment-production-2.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoHadam committed Jan 2, 2024
1 parent 71a02cb commit 890312f
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions .github/workflows/deploy-production-2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# 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://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Deploy production-2 server to ec2

on:
Expand All @@ -10,28 +7,41 @@ on:
- production-2

jobs:
build:
runs-on: self-hosted
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.SERVER_PROFILE }}

steps:
- uses: actions/checkout@v2
with:
path: ${{ env.SERVER_PROFILE }}
- name: Checkout Repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env
- run: bash ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh

- name: Deploy to EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json &&
cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env &&
cd ${{ env.PROJECT_PATH }} &&
git fetch --all &&
git checkout ${{ env.BRANCH_NAME }} &&
git pull origin ${{ env.BRANCH_NAME }} &&
bash script/prebuild.sh &&
bash script/reload.sh
env:
BRANCH_NAME: production-2
NODE_ENV: production
SERVER_PROFILE: production-2
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production-2

0 comments on commit 890312f

Please sign in to comment.