Skip to content

Commit 6434044

Browse files
authored
refactor: Update GitHub Actions CI configuration to improve caching s… (#404)
* refactor: Update GitHub Actions CI configuration to improve caching strategy * refactor: Enhance caching strategy in GitHub Actions CI configuration * refactor: Improve pnpm setup and caching in GitHub Actions - Updated action.yml to extract both pnpm and node versions from .tool-versions. - Enhanced caching strategy by including node_modules and .pnpm-store in cache paths. - Modified install command to use --frozen-lockfile for consistency. * refactor: Remove provenance option from caching in GitHub Actions CI configuration * refactor: Fix node version extraction in GitHub Actions setup - Updated action.yml to correctly extract the node version from .tool-versions. - Ensured both pnpm and node versions are outputted to $GITHUB_OUTPUT for consistency.
1 parent c6ddcba commit 6434044

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

.github/actions/setup-pnpm/action.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
name: "Setup pnpm"
2-
description: "Sets up pnpm with caching"
2+
description: "Sets up pnpm with caching and installation"
33

44
runs:
55
using: composite
66
steps:
7-
- name: Extract pnpm version from .tool-versions
8-
id: pnpm-version
7+
- name: Extract versions from .tool-versions
8+
id: versions
99
shell: bash
1010
run: |
1111
PNPM_VERSION=$(grep 'pnpm' .tool-versions | awk '{print $2}')
12-
echo "Using pnpm version: $PNPM_VERSION"
13-
echo "version=$PNPM_VERSION" >> $GITHUB_OUTPUT
12+
NODE_VERSION=$(grep 'nodejs' .tool-versions | awk '{print $2}')
13+
echo "pnpm=$PNPM_VERSION" >> $GITHUB_OUTPUT
14+
echo "node=$NODE_VERSION" >> $GITHUB_OUTPUT
1415
1516
- name: Setup pnpm
1617
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
1718
with:
18-
version: ${{ steps.pnpm-version.outputs.version }}
19+
version: ${{ steps.versions.outputs.pnpm }}
1920

2021
- name: Get pnpm store directory
2122
shell: bash
22-
run: |
23-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
23+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
2424

2525
- name: Restore pnpm cache
2626
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
2727
with:
28-
path: ${{ env.STORE_PATH }}
29-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
28+
path: |
29+
${{ env.STORE_PATH }}
30+
node_modules
31+
.pnpm-store
32+
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
3033
restore-keys: |
31-
${{ runner.os }}-pnpm-
34+
${{ runner.os }}-node-${{ steps.versions.outputs.node }}-pnpm-
3235
3336
- name: Install dependencies
3437
shell: bash
35-
run: pnpm install
38+
run: pnpm install --frozen-lockfile

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ jobs:
5656
# Set up Docker Buildx
5757
- name: Set up Docker Buildx
5858
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
59-
with:
60-
driver-opts: |
61-
image=moby/buildkit:v0.12.0
6259
# Login to GitHub Container Registry
6360
- name: Login to GitHub Container Registry
6461
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
@@ -88,8 +85,13 @@ jobs:
8885
push: ${{ github.event_name != 'pull_request' }}
8986
tags: ${{ steps.meta.outputs.tags }}
9087
labels: ${{ steps.meta.outputs.labels }}
91-
cache-from: type=gha
92-
cache-to: type=gha,mode=max
88+
platforms: linux/amd64,linux/arm64
89+
cache-from: |
90+
type=gha,scope=${{ github.ref_name }}-${{ github.job }}
91+
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
92+
cache-to: |
93+
type=gha,mode=max,scope=${{ github.ref_name }}-${{ github.job }}
94+
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
9395
9496
summary:
9597
name: Workflow Summary

0 commit comments

Comments
 (0)