1616 types :
1717 - labeled
1818 merge_group :
19+ workflow_dispatch :
1920
2021defaults :
2122 run :
@@ -26,15 +27,18 @@ permissions:
2627 contents : read
2728 actions : read
2829
30+ env :
31+ # See https://turbo.build/repo/docs/reference/command-line-reference/run#--cache-dir
32+ TURBO_ARGS : --cache-dir=.turbo/cache
33+ # See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
34+ TURBO_FORCE : true
35+
2936jobs :
3037 build :
31- # This Job should run either on `merge_groups` or `push` events
38+ # This Job should run either on non-`pull_request_target` events,
3239 # or `pull_request_target` event with a `labeled` action with a label named `github_actions:pull-request`
33- # since we want to run Website Builds on all these 3 occasions. As this allows us to be certain the that builds are passing
34- if : |
35- (github.event_name == 'push' || github.event_name == 'merge_group') ||
36- (github.event_name == 'pull_request_target' &&
37- github.event.label.name == 'github_actions:pull-request')
40+ # since we want to run Website Builds on all these occasions. As this allows us to be certain the that builds are passing
41+ if : github.event_name != 'pull_request_target' || github.event.label.name == 'github_actions:pull-request'
3842
3943 name : Build on ${{ matrix.os }}
4044 runs-on : ${{ matrix.os }}
5054 with :
5155 egress-policy : audit
5256
53- - name : Provide Turborepo Arguments
54- # This step is responsible for providing a reusable string that can be used within other steps and jobs
55- # that use the `turbo` cli command as a way of easily providing shared arguments to the `turbo` command
56- id : turborepo_arguments
57- # See https://turbo.build/repo/docs/reference/command-line-reference/run#--cache-dir
58- # See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
59- run : echo "turbo_args=--force=true --cache-dir=.turbo/cache" >> "$GITHUB_OUTPUT"
60-
6157 - name : Use GNU tar instead BSD tar
6258 # This ensures that we use GNU `tar` which is more efficient for extracting caches's
6359 if : matrix.os == 'windows-latest'
@@ -78,34 +74,29 @@ jobs:
7874
7975 - uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
8076 with :
81- # See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
82- path : |
83- ~/.npm
84- ${{ github.workspace }}/apps/site/.next/cache
85- # Generate a new cache whenever packages or source files change.
86- key : ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
87- # If source files changed but packages didn't, rebuild from a prior cache.
88- restore-keys : |
89- ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
77+ path : ${{ github.workspace }}/apps/site/.next/cache
78+ key : ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
79+ restore-keys : ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
80+
81+ - name : Set up pnpm
82+ uses : pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
83+ with :
84+ cache : true
9085
9186 - name : Set up Node.js
9287 uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
9388 with :
9489 # We want to ensure that the Node.js version running here respects our supported versions
9590 node-version-file : ' .nvmrc'
96- cache : ' npm '
91+ cache : ' pnpm '
9792
98- - name : Install npm packages
99- # We want to avoid npm from running the Audit Step and Funding messages on a CI environment
100- # We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
101- # We also use `--omit=dev` to avoid installing devDependencies as we don't need them during the build step
102- run : npm i --no-audit --no-fund --userconfig=/dev/null --omit=dev
93+ - name : Install packages
94+ # We only want to install required production packages
95+ run : pnpm install --prod --frozen-lockfile
10396
10497 - name : Build Next.js (ISR)
10598 # We want a ISR build on CI to ensure that regular Next.js builds work as expected.
106- # We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
107- # the `${{ steps.turborepo_arguments.outputs.turbo_args }}` is a string substitution coming from a previous step
108- run : npx --package=turbo@latest -- turbo build ${{ steps.turborepo_arguments.outputs.turbo_args }}
99+ run : pnpm exec turbo build ${{ env.TURBO_ARGS }}
109100 env :
110101 # We want to ensure we have enough RAM allocated to the Node.js process
111102 # this should be a last resort in case by any chances the build memory gets too high
@@ -118,9 +109,7 @@ jobs:
118109 # We only run full static builds within Pull Requests. This step is also used to export
119110 # static output in all languages, and it only works on `push` events.
120111 if : github.event_name == 'push'
121- # We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
122- # the `${{ steps.turborepo_arguments.outputs.turbo_args }}` is a string substitution coming from a previous step
123- run : npx --package=turbo@latest -- turbo deploy ${{ steps.turborepo_arguments.outputs.turbo_args }}
112+ run : pnpm exec turbo deploy ${{ env.TURBO_ARGS }}
124113 env :
125114 # We want to ensure we have enough RAM allocated to the Node.js process
126115 # this should be a last resort in case by any chances the build memory gets too high
@@ -139,9 +128,7 @@ jobs:
139128 if : |
140129 (github.event_name == 'pull_request_target' &&
141130 github.event.pull_request.head.ref != 'chore/crowdin')
142- # We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
143- # the `${{ steps.turborepo_arguments.outputs.turbo_args }}` is a string substitution coming from a previous step
144- run : npx --package=turbo@latest -- turbo deploy ${{ steps.turborepo_arguments.outputs.turbo_args }}
131+ run : pnpm exec turbo deploy ${{ env.TURBO_ARGS }}
145132 env :
146133 # We want to ensure we have enough RAM allocated to the Node.js process
147134 # this should be a last resort in case by any chances the build memory gets too high
@@ -154,14 +141,12 @@ jobs:
154141
155142 - name : Sync Orama Cloud
156143 # We only want to sync the Orama Cloud production indexes on `push` events.
157- # We also want to sync the Orama Cloud preview (deployment) indexes on `pull_request_target` events.
144+ # We also want to sync the Orama Cloud preview (deployment) indexes on `pull_request_target` events (or manual triggers) .
158145 # We also want to ensure that the sync only happens on the `ubuntu-latest` runner to avoid duplicate syncs
159146 # or Windows-based path issues.
160147 env :
161148 ORAMA_INDEX_ID : ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_INDEX_ID || secrets.ORAMA_INDEX_ID }}
162149 ORAMA_SECRET_KEY : ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_SECRET_KEY || secrets.ORAMA_SECRET_KEY }}
163- if : |
164- (matrix.os == 'ubuntu-latest') &&
165- ((github.event_name == 'push') || (github.event_name == 'pull_request_target'))
166- run : |
167- cd apps/site && npm run sync-orama
150+ if : matrix.os == 'ubuntu-latest' && github.event_name != 'merge_group'
151+ working-directory : apps/site
152+ run : pnpm sync-orama
0 commit comments