update: Implement PM2 deployment on CD #17
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: Deployment | |
on: | |
push: | |
branches: ['main'] | |
jobs: | |
deploy: | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
cache-dependency-path: '**/pnpm-lock.yaml' # Needed to use multiple directories | |
- name: Setup CMS | |
run: | | |
touch .env | |
echo "${{ secrets.CMS_ENV }}" | base64 --decode > .env | |
pnpm install | |
pnpm build | |
working-directory: ./server | |
- name: Setup Client | |
run: | | |
touch .env | |
echo "${{ secrets.CLIENT_ENV }}" | base64 --decode > .env | |
pnpm install | |
pnpm build | |
working-directory: ./client | |
- name: Restart PM2 | |
run: | | |
touch pm2.config.js | |
echo "${{ secrets.PM2_CONFIG }}" | base64 --decode > pm2.config.js | |
pm2 restart pm2.config.js |