-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor deploy-development.yml and reload.sh for CI/CD performance (#…
…535) * Rollback deploy file to test with Github Hosted Runner * Update branch name to push * Add step to check default github workspace path * Add path option for actions/checkout * Delete unnecessary code * Use bash instead of sh * Get the latest changes from the branch * Manage branch name with environment variable * Use '&&' to ensure each step runs successfully * Write branch name directly * Fetch all branches from remote repository * Update reload.sh to delete duplicate code and clarify roles * Remove git reset and leave only git pull * Reflect the changes so far in deployment-development.yml * Delete the file for testing using Github Hosted Runner * Delete code for checking github workspace path * Reflect the changes so far in deployment-production-1.yml * Reflect the changes so far in deployment-production-2.yml * Reflect the changes so far in deployment-production.yml
- Loading branch information
Showing
5 changed files
with
91 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
# 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 server to ec2 | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
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: main | ||
NODE_ENV: production | ||
SERVER_PROFILE: production | ||
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters