|
| 1 | +name: Build Next.js examples |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + types: [opened, reopened, synchronize] |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + max-parallel: 4 |
| 13 | + fail-fast: true |
| 14 | + matrix: |
| 15 | + example: |
| 16 | + [ |
| 17 | + asset-list, |
| 18 | + authz, |
| 19 | + vote-proposal, |
| 20 | + ibc-transfer, |
| 21 | + swap-tokens, |
| 22 | + provide-liquidity, |
| 23 | + nft, |
| 24 | + connect-chain, |
| 25 | + connect-multi-chain, |
| 26 | + ] |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set template_path Environment Variable |
| 33 | + run: | |
| 34 | + example_value="${{ matrix.example }}" |
| 35 | +
|
| 36 | + if [[ "$example_value" == "connect-chain" ]] || [[ "$example_value" == "connect-multi-chain" ]]; then |
| 37 | + echo "template_path=templates" >> $GITHUB_ENV |
| 38 | + echo "ci_template_path=dest" >> $GITHUB_ENV |
| 39 | + else |
| 40 | + echo "template_path=examples" >> $GITHUB_ENV |
| 41 | + echo "ci_template_path=dest" >> $GITHUB_ENV |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Log |
| 45 | + run: | |
| 46 | + echo "Using template_path: $template_path" |
| 47 | + echo "Using ci_template_path: $ci_template_path" |
| 48 | +
|
| 49 | + - name: Clone example |
| 50 | + run: | |
| 51 | + echo "Cloning example: ./$template_path/${{ matrix.example }}/" into "${{ github.workspace }}/$ci_template_path/${{ matrix.example }}" |
| 52 | +
|
| 53 | + mkdir -p ${{ github.workspace }}/$ci_template_path/${{ matrix.example }} |
| 54 | + cp -r ./$template_path/${{ matrix.example }}/ ${{ github.workspace }}/$ci_template_path/ |
| 55 | + cd ${{ github.workspace }}/$ci_template_path/${{ matrix.example }} |
| 56 | +
|
| 57 | + - name: Set up Node.js |
| 58 | + uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version: 20 |
| 61 | + |
| 62 | + - name: Set up Yarn |
| 63 | + |
| 64 | + |
| 65 | + - name: Cache NextJS |
| 66 | + uses: actions/cache@v4 |
| 67 | + with: |
| 68 | + path: | |
| 69 | + ${{ github.workspace }}/.next/cache |
| 70 | + # Generate a new cache whenever packages or source files change. |
| 71 | + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} |
| 72 | + # If source files changed but packages didn't, rebuild from a prior cache. |
| 73 | + restore-keys: | |
| 74 | + ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- |
| 75 | +
|
| 76 | + - name: Build example project |
| 77 | + run: | |
| 78 | + echo "Building example: ${{ matrix.example }} in directory ${{ github.workspace }}/$ci_template_path/${{ matrix.example }}" |
| 79 | + cd ${{ github.workspace }}/$ci_template_path/${{ matrix.example }} |
| 80 | + ls -la |
| 81 | + yarn install |
| 82 | + yarn build |
0 commit comments