diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 31c7875b7..29eadb2e0 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -38,10 +38,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: 'yarn' - name: Install dependencies - run: yarn --immutable + uses: ./packages/actions/src/yarnCache - name: Build dependencies run: yarn build @@ -81,10 +80,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: 'yarn' - name: Install dependencies - run: yarn --immutable + uses: ./packages/actions/src/yarnCache - name: Build actions run: yarn workspace @discordjs/actions build diff --git a/.github/workflows/npm-auto-deprecate.yml b/.github/workflows/npm-auto-deprecate.yml index 9774b2f25..c57e71e67 100644 --- a/.github/workflows/npm-auto-deprecate.yml +++ b/.github/workflows/npm-auto-deprecate.yml @@ -16,10 +16,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: 'yarn' - name: Install dependencies - run: yarn --immutable + uses: ./packages/actions/src/yarnCache - name: Deprecate versions run: 'yarn npm-deprecate --name "*dev*" --package @discordjs/brokers @discordjs/builders @discordjs/collection discord.js @discordjs/proxy @discordjs/rest @discordjs/util @discordjs/voice @discordjs/ws' diff --git a/.github/workflows/publish-dev.yml b/.github/workflows/publish-dev.yml index ea51cee9b..2630fe615 100644 --- a/.github/workflows/publish-dev.yml +++ b/.github/workflows/publish-dev.yml @@ -42,10 +42,9 @@ jobs: with: node-version: 16 registry-url: https://registry.npmjs.org/ - cache: 'yarn' - name: Install dependencies - run: yarn --immutable + uses: ./packages/actions/src/yarnCache - name: Build dependencies run: yarn build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 901c90045..371758b99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,10 +20,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: 'yarn' - name: Install dependencies - run: yarn install --immutable + uses: ./packages/actions/src/yarnCache - name: Build dependencies run: yarn build diff --git a/packages/actions/src/yarnCache/action.yml b/packages/actions/src/yarnCache/action.yml new file mode 100644 index 000000000..dd0a4235d --- /dev/null +++ b/packages/actions/src/yarnCache/action.yml @@ -0,0 +1,35 @@ +name: 'yarn install' +description: 'Run yarn install with node_modules linker and cache enabled' +runs: + using: 'composite' + steps: + - name: Expose yarn config as "$GITHUB_OUTPUT" + id: yarn-config + shell: bash + run: | + echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-download-cache + with: + path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} + key: yarn-download-cache-${{ hashFiles('yarn.lock') }} + restore-keys: | + yarn-download-cache- + + - name: Restore yarn install state + id: yarn-install-state-cache + uses: actions/cache@v3 + with: + path: .yarn/ci-cache/ + key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} + + - name: Install dependencies + shell: bash + run: | + yarn install --immutable --inline-builds + env: + YARN_ENABLE_GLOBAL_CACHE: 'false' + YARN_NM_MODE: 'hardlinks-local' + YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz