Hotfix: update deploy.yaml #13
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: DDocker to AWS EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Launch Express WAS with pm2 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.15.0] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8.10.5 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Get PNPM cache directory | |
id: pnpm-cache-dir | |
run: | | |
echo "::set-output name=dir::$(pnpm config get store-dir)" | |
- uses: actions/cache@v3 | |
id: pnpm-cache | |
with: | |
path: ${{ steps.pnpm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: pnpm install | |
- name: SSH deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.AWS_SSH_HOST }} | |
username: ${{ secrets.AWS_SSH_USERNAME }} | |
password: ${{ secrets.AWS_SSH_PASSWORD }} | |
key: ${{ secrets.AWS_SSH_KEY }} | |
port: 22 | |
script: | | |
sudo su -c 'cd /root/DDocker_BE' | |
sudo su -c 'git pull origin main' | |
sudo su -c 'pm2 reload DDocker_API' |