Merge branch 'release/V1.0.1' into main #21
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
name: Deploy to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
node-version: [18.12.1] | |
steps: | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# build_args: REACT_APP_ADMIN_KEY=${{ secrets.REACT_APP_ADMIN_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up environment variable | |
run: echo "REACT_APP_API=${{ secrets.REACT_APP_API }}" >> .env | |
- name: Install dependencies and build | |
run: | | |
npm install --save --legacy-peer-deps | |
npm run build | |
- name: zip create # S3에 올릴 zip 파일 생성. (빌드한 프로젝트를 압축) | |
run: zip -qq -r ./build.zip . | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: pcot-web-artifact | |
path: build.zip | |
deploy: | |
needs: build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: delete all file | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.WEB_HOST_ID }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
rm -rf /home/ubuntu/pcot | |
- name: mdir pcot | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.WEB_HOST_ID }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
mkdir pcot | |
- name: Download artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: pcot-web-artifact | |
- name: Transfer Deploy Script use SCP | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.WEB_HOST_ID }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
source: "*.zip" | |
target: "~/" | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.WEB_HOST_ID }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
sh /home/ubuntu/deploy/deploy.sh |