From f36a37875357fb2df9a75006ba23db326345570f Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Wed, 14 Dec 2022 15:24:52 +0100 Subject: [PATCH] must run on pushes to make cache warm (#33491) --- .github/workflows/keep-caches-warm.yml | 48 ++++++++++++++++++++++++++ .github/workflows/link-check-daily.yml | 2 +- .github/workflows/link-check-on-pr.yml | 15 ++++---- 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/keep-caches-warm.yml diff --git a/.github/workflows/keep-caches-warm.yml b/.github/workflows/keep-caches-warm.yml new file mode 100644 index 0000000000..bdefacf8b4 --- /dev/null +++ b/.github/workflows/keep-caches-warm.yml @@ -0,0 +1,48 @@ +name: Keep caches warm + +# **What it does**: Makes sure the caching of ./node_modules and ./.next +# is kept warm for making pull requests more rapid. +# **Why we have it**: A PR workflow that depends on caching can't reuse a +# cached artifact acorss PRs unless it also runs on `main`. +# **Who does it impact**: Docs engineering, open-source engineering contributors. + +on: + workflow_dispatch: + push: + branches: + - main + +permissions: + contents: read + +jobs: + keep-caches-warm: + if: github.repository == 'github/docs-internal' || github.repository == 'github/docs' + runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }} + steps: + - name: Check out repo + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + + - name: Cache node_modules + uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }} + + - name: Setup node + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 + with: + node-version: '16.17.0' + cache: npm + + - name: Install dependencies + run: npm install --prefer-offline --no-audit --ignore-scripts + + - name: Cache nextjs build + uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 + with: + path: .next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }} + + - name: Build + run: npm run build diff --git a/.github/workflows/link-check-daily.yml b/.github/workflows/link-check-daily.yml index 11053b49df..a324943725 100644 --- a/.github/workflows/link-check-daily.yml +++ b/.github/workflows/link-check-daily.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Node uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 with: - node-version: '16.15.0' + node-version: '16.17.0' cache: npm - name: Install dependencies diff --git a/.github/workflows/link-check-on-pr.yml b/.github/workflows/link-check-on-pr.yml index d9ffd60f7b..13d00a5eea 100644 --- a/.github/workflows/link-check-on-pr.yml +++ b/.github/workflows/link-check-on-pr.yml @@ -7,9 +7,6 @@ name: 'Link Checker: On PR' on: workflow_dispatch: merge_group: - push: - branches: - - main pull_request: permissions: @@ -31,14 +28,20 @@ jobs: - name: Checkout uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Cache node_modules + uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }} + - name: Setup node uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 with: - node-version: '16.15.0' + node-version: '16.17.0' cache: npm - - name: Install - run: npm ci --ignore-scripts + - name: Install dependencies + run: npm install --prefer-offline --no-audit --ignore-scripts - name: Figure out which docs-early-access branch to checkout, if internal repo if: ${{ github.repository == 'github/docs-internal' }}