Github的Actions 的npm install为什么那么慢呢?

Github的Actions 的npm install为什么那么慢呢?

已经有人发了这篇paper:

https://dwye.dev/post/github-action-npm-cache/

这样子写之后,NB快哦,只用20秒就能完成发布了呢;

name: CI

on:
  push:
    branches: [ "master" ]

env:
  GIT_USER: XXXX
  GIT_EMAIL: XXXX@qq.com
  THEME_REPO: XXXX/hexo-theme-next
  THEME_BRANCH: master
  DEPLOY_REPO: XXXX/XXXX.github.io
  DEPLOY_BRANCH: master

jobs:
  build:
    name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [ubuntu-latest]
        node_version: [13.14.0]    

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Checkout theme repo
        uses: actions/checkout@v3
        with:
          repository: ${{ env.THEME_REPO }}
          ref: ${{ env.THEME_BRANCH }}
          path: themes/next            

      - name: Configuration environment
        env:
          HEXO_DEPLOY_PRI: ${{secrets.HEXO_DEPLOY_PRI}}
        run: |
          sudo timedatectl set-timezone "Asia/Shanghai"
          mkdir -p ~/.ssh/                              
          echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          git config --global user.name $GIT_USER
          git config --global user.email $GIT_EMAIL 

      - name: Use Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node_version }}
          cache: 'npm'

      - name: Install Dependencies
        run: |
          npm ci           

      - name: Deploy hexo
        run: |
          npm run deploy
posted @ 2022-11-07 10:43  bH1pJ  阅读(85)  评论(0编辑  收藏  举报