Skip to content

adds cache step to CI #38

adds cache step to CI

adds cache step to CI #38

Workflow file for this run

name: CI and Deployment

Check failure on line 1 in .github/workflows/deployment.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/deployment.yaml

Invalid workflow file

Invalid `steps` value - steps should be list of `uses` or `run` items
on:
push:
branches:
- main
jobs:
cache:
runs-on: ubuntu-latest
steps:
uses: actions/cache@v3
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
build:
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install Dependencies
run: npm install
- name: Generate date and write to file
run: echo "const buildDate = '`date +%Y%m%d%H%M`'; export default buildDate;" > buildDate.ts
- name: Build
run: npm run buildfordeploy
- name: Prepare files
run: |
cp -r public .next/standalone
cp -r ./.next/static .next/standalone/.next
- name: Archive files
uses: actions/upload-artifact@v2
with:
name: app
path: .next/standalone
deploy:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Download files
uses: actions/download-artifact@v2
with:
name: app
path: temporaryfolder
- name: copy file via ssh password
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: temporaryfolder/*
target: /home/${{ secrets.USERNAME }}/servers/belief/standalone
strip_components: 1
- name: executing remote ssh commands
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cp /home/${{ secrets.USERNAME }}/servers/.env /home/${{ secrets.USERNAME }}/servers/belief/standalone/.env
sed -i 's/3000/3002/g' /home/${{ secrets.USERNAME }}/servers/belief/standalone/server.js
pm2 restart /home/${{ secrets.USERNAME }}/servers/belief/standalone/server.js --name belief
pm2 save