-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from boostcampwm-2024/back/main
[BE] alpha 서버 배포 (11.07)
- Loading branch information
Showing
45 changed files
with
4,176 additions
and
9,994 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [back/main, front/main] | ||
pull_request: | ||
branches: [main, back/main, dev] | ||
|
||
jobs: | ||
BE-test-and-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'npm' | ||
cache-dependency-path: ./BE/package-lock.json | ||
|
||
- name: Install dependencies | ||
working-directory: ./BE | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: npm test | ||
working-directory: ./BE | ||
env: | ||
CI: true | ||
|
||
- name: Run linter | ||
working-directory: ./BE | ||
run: npm run lint | ||
|
||
- name: Build application | ||
working-directory: ./BE | ||
run: npm run build | ||
|
||
FE-test-and-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'npm' | ||
cache-dependency-path: ./BE/package-lock.json | ||
|
||
- name: Install dependencies | ||
working-directory: ./FE | ||
run: npm ci | ||
|
||
- name: Run linter | ||
working-directory: ./FE | ||
run: npm run lint | ||
|
||
- name: Build application | ||
working-directory: ./FE | ||
run: npm run build |
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 |
---|---|---|
|
@@ -24,6 +24,11 @@ jobs: | |
cache: 'npm' | ||
cache-dependency-path: ./BE/package-lock.json | ||
|
||
- name: Create .env file | ||
run: | | ||
touch ./BE/.env | ||
echo "${{ secrets.ENV }}" > ./BE/.env | ||
- name: Install dependencies | ||
working-directory: ./BE | ||
run: npm ci | ||
|
@@ -60,6 +65,26 @@ jobs: | |
docker push ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} | ||
docker push ${{ env.DOCKER_IMAGE }}:latest | ||
- name: Get Github Actions IP | ||
id: ip | ||
uses: haythem/[email protected] | ||
|
||
- name: Setting NCP CLI & Credentials | ||
run: | | ||
cd ~ | ||
wget https://www.ncloud.com/api/support/download/5/65 | ||
unzip 65 | ||
mkdir ~/.ncloud | ||
echo -e "[DEFAULT]\nncloud_access_key_id = ${{ secrets.NCP_ACCESS_KEY }}\nncloud_secret_access_key = ${{ secrets.NCP_SECRET_KEY }}\nncloud_api_url = ${{ secrets.NCP_API_URI }}" >> ~/.ncloud/configure | ||
- name: Add Github Action Ip to Security group | ||
run: | | ||
cd ~ | ||
ls -la | ||
chmod -R 777 ~/cli_linux | ||
cd ~/cli_linux | ||
./ncloud vserver addAccessControlGroupInboundRule --regionCode KR --vpcNo ${{ secrets.NCP_VPC_ID }} --accessControlGroupNo ${{ secrets.NCP_ACG_ID }} --accessControlGroupRuleList "protocolTypeCode='TCP', ipBlock='${{ steps.ip.outputs.ipv4 }}/32', portRange='${{ secrets.SSH_PORT }}'" | ||
- name: Deploy to NCP Server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
|
@@ -68,10 +93,20 @@ jobs: | |
key: ${{ secrets.NCP_SERVER_SSH_KEY }} | ||
port: 22 | ||
script: | | ||
docker system prune -af | ||
echo "${{ secrets.ENV }}" > .env | ||
docker pull ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} | ||
docker stop ${{ env.DOCKER_IMAGE }} || true | ||
docker stop juga-docker || true | ||
docker rm juga-docker || true | ||
docker run -d \ | ||
--name juga-docker \ | ||
-p 3000:3000 \ | ||
--env-file .env \ | ||
${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} | ||
- name: Remove Github Action Ip to Security group | ||
run: | | ||
chmod -R 777 ~/cli_linux | ||
cd ~/cli_linux | ||
./ncloud vserver removeAccessControlGroupInboundRule --regionCode KR --vpcNo ${{ secrets.NCP_VPC_ID }} --accessControlGroupNo ${{ secrets.NCP_ACG_ID }} --accessControlGroupRuleList "protocolTypeCode='TCP', ipBlock='${{ steps.ip.outputs.ipv4 }}/32', portRange='${{ secrets.SSH_PORT }}'" |
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
Oops, something went wrong.