Fix CI test jobs fail to detect build failure #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Next.js Examples | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
jobs: | |
find-packages: | |
runs-on: ubuntu-latest | |
outputs: | |
packages: ${{ steps.find-packages.outputs.packages }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Find Next.js packages | |
id: find-packages | |
run: | | |
packages=$(ls -d examples/* | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
echo "::set-output name=packages::$packages" | |
echo "packages=$packages" >> $GITHUB_ENV | |
shell: bash | |
- name: Debug packages output | |
run: echo ${{ steps.find-packages.outputs.packages }} | |
build: | |
needs: find-packages | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: ${{ fromJson(needs.find-packages.outputs.packages) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # Ensure this matches your Node.js version | |
- name: Install Yarn | |
run: | | |
corepack enable | |
corepack prepare [email protected] --activate | |
- name: Install dependencies | |
working-directory: ${{ matrix.package }} | |
run: yarn install | |
- name: Build Next.js project | |
working-directory: ${{ matrix.package }} | |
run: yarn build |