diff --git a/.github/workflows/nodejs-ci.yml b/.github/workflows/nodejs-ci.yml index 3459dc8..6ce3c9b 100644 --- a/.github/workflows/nodejs-ci.yml +++ b/.github/workflows/nodejs-ci.yml @@ -15,23 +15,31 @@ jobs: node-version: [18.x] steps: - - uses: actions/checkout@v3 - - - name: Set up Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - - run: npm ci - - - name: Set environment variables - run: | - touch .env - echo "${{ secrets.PROD_SECRET }}" > .env - - - name: Install PM2 - run: npm install -g pm2 - - - name: Start application with PM2 - run: pm2 restart dist/index.js --interpreter node + - uses: actions/checkout@v3 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' # This line enables automatic caching for npm dependencies + + - name: Cache Node.js modules + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - run: npm ci + + - name: Set environment variables + run: | + touch .env + echo "${{ secrets.PROD_SECRET }}" > .env + + - name: Install PM2 + run: npm install -g pm2 + + - name: Start application with PM2 + run: pm2 restart dist/index.js --interpreter node