Skip to content

Commit

Permalink
Refactor/issue 464 sepreate env files by profile (#465)
Browse files Browse the repository at this point in the history
* [Refact] Copy different environment files according to NODE_ENV

* [Fix] Upgrade node version

* [Fix] Use SERVER_PROFILE instead of SERVER_NAME
  • Loading branch information
ChoHadam authored Jan 19, 2023
1 parent 6e31f3a commit 381fe47
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/deploy-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.NODE_ENV }}
working-directory: ${{ env.SERVER_PROFILE }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0
with:
path: ${{ env.NODE_ENV }}
path: ${{ env.SERVER_PROFILE }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 #v.3.5.1
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.NODE_ENV }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/.env ${{ env.PROJECT_PATH }}/.env
- 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: sh ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh
env:
NODE_ENV: development
SERVER_PROFILE: development
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/development
13 changes: 7 additions & 6 deletions .github/workflows/deploy-production-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ jobs:
runs-on: self-hosted
strategy:
matrix:
node-version: [12.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.NODE_ENV }}
working-directory: ${{ env.SERVER_PROFILE }}
steps:
- uses: actions/checkout@v2
with:
path: ${{ env.NODE_ENV }}
path: ${{ env.SERVER_PROFILE }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.NODE_ENV }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/.env ${{ env.PROJECT_PATH }}/.env
- 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: sh ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh
env:
NODE_ENV: production-1
NODE_ENV: production
SERVER_PROFILE: production-1
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production-1
13 changes: 7 additions & 6 deletions .github/workflows/deploy-production-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ jobs:
runs-on: self-hosted
strategy:
matrix:
node-version: [12.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.NODE_ENV }}
working-directory: ${{ env.SERVER_PROFILE }}
steps:
- uses: actions/checkout@v2
with:
path: ${{ env.NODE_ENV }}
path: ${{ env.SERVER_PROFILE }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.NODE_ENV }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/.env ${{ env.PROJECT_PATH }}/.env
- 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: sh ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh
env:
NODE_ENV: production-2
NODE_ENV: production
SERVER_PROFILE: production-2
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production-2
11 changes: 6 additions & 5 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ jobs:
runs-on: self-hosted
strategy:
matrix:
node-version: [12.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.NODE_ENV }}
working-directory: ${{ env.SERVER_PROFILE }}
steps:
- uses: actions/checkout@v2
with:
path: ${{ env.NODE_ENV }}
path: ${{ env.SERVER_PROFILE }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.NODE_ENV }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/.env ${{ env.PROJECT_PATH }}/.env
- 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: sh ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh
env:
NODE_ENV: production
SERVER_PROFILE: production
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production
2 changes: 1 addition & 1 deletion .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.NODE_ENV }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/.env ${{ env.PROJECT_PATH }}/.env
- run: cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env
# - run: sudo ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: ${{ env.PROJECT_PATH }}/script/reload.sh
env:
Expand Down

0 comments on commit 381fe47

Please sign in to comment.