Skip to content

Update Node.js to v22 #2998

Update Node.js to v22

Update Node.js to v22 #2998

name: Build and Deploy
on:
push:
branches:
- live
- main
- 'renovate/**'
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
name: Setup NodeJS
with:
node-version-file: '.tool-versions'
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
name: "Next JS Cache"
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- run: pnpm build
- run: |
mkdir dist
mkdir -p app/standalone/public
cp ./package.json app
cp -r .next/standalone app
cp .next/static app/standalone/.next/ -r
cp -r public/* app/standalone/public/
cp ecosystem.config.js app
tar -cJf dist/standalone-dist.tar.xz app
name: Create artifact
- name: Upload artifact
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4
with:
name: nodejs-app
path: ./dist/standalone-dist.tar.xz
retention-days: 3
deploy:
needs: 'build'
name: Deploy to server
if: github.ref == 'refs/heads/live'
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: nodejs-app
- name: Copy artifact to the server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
source: "standalone-dist.tar.xz"
target: "/srv/http/pnf/"
- name: Setup Node JS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
rm -rf app && tar --overwrite -xf standalone-dist.tar.xz
cd app && pm2 restart ecosystem.config.js