workbox cache first static pages #338
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 OCI | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "master" ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: SSH Remote Commands | |
uses: appleboy/[email protected] | |
env: | |
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: ${{ github.sha }} | |
with: | |
# ssh host | |
host: ${{ secrets.OCI_VM_IP }} | |
username: ${{ secrets.OCI_VM_USERNAME }} | |
key: ${{ secrets.OCI_VM_SSH }} | |
envs: NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA | |
# execute commands | |
script: | | |
cd ~/matheditor | |
echo "Pulling latest changes..." | |
git fetch | |
git reset --hard origin/master | |
echo "Installing dependencies..." | |
npm ci -f | |
npx prisma migrate deploy | |
echo "Copying cache..." | |
mkdir -p temp && cp -r .next/cache temp | |
echo "Building to temp directory..." | |
BUILD_DIR=temp npm run build || exit | |
if [ ! -f "temp/BUILD_ID" ]; then | |
echo '\033[31m Build failed!\033[0m' | |
exit 1; | |
fi | |
echo "Switching live directory..." | |
rm -rf .next | |
mv temp .next | |
pm2 reload matheditor --update-env | |
echo "Deploy done." |