|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Install Node.js |
| 18 | + uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version-file: .nvmrc |
| 21 | + cache: "npm" |
| 22 | + |
| 23 | + - name: Get npm cache directory |
| 24 | + id: npm-cache-dir |
| 25 | + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} |
| 26 | + |
| 27 | + - name: Cache npm dependencies |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 31 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-node- |
| 34 | +
|
| 35 | + - name: Check Node version |
| 36 | + run: node -v |
| 37 | + |
| 38 | + - name: Setup NPM |
| 39 | + run: npm install -g npm@latest |
| 40 | + |
| 41 | + - name: Check Node version |
| 42 | + run: npm -v |
| 43 | + |
| 44 | + - name: Install Node dependencies |
| 45 | + run: npm install |
| 46 | + |
| 47 | + - name: Build JavaScript |
| 48 | + run: npm run build |
| 49 | + |
| 50 | + - name: Setup PHP |
| 51 | + uses: shivammathur/setup-php@v2 |
| 52 | + with: |
| 53 | + php-version: "8.4" |
| 54 | + coverage: none |
| 55 | + tools: composer:v2 |
| 56 | + |
| 57 | + - name: Get Composer cache directory |
| 58 | + id: composer-cache |
| 59 | + run: echo "dir=$(composer config cache-files-dir)" >> ${GITHUB_OUTPUT} |
| 60 | + |
| 61 | + - name: Cache Composer dependencies |
| 62 | + uses: actions/cache@v4 |
| 63 | + with: |
| 64 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 65 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 66 | + restore-keys: | |
| 67 | + ${{ runner.os }}-composer- |
| 68 | +
|
| 69 | + - name: PHP Version |
| 70 | + run: php -v |
| 71 | + |
| 72 | + - name: Install Root dependencies |
| 73 | + run: composer install --no-dev --prefer-dist --no-progress |
| 74 | + |
| 75 | + - name: Install Plugin dependencies |
| 76 | + run: composer install --no-dev --prefer-dist --no-progress --working-dir=mu-plugins/10up-plugin |
| 77 | + |
| 78 | + - name: Install Theme dependencies |
| 79 | + run: composer install --no-dev --prefer-dist --no-progress --working-dir=themes/10up-theme |
| 80 | + |
| 81 | + - name: Upload build artifact |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: ${{ inputs.name }}-payload |
| 85 | + retention-days: 7 |
| 86 | + include-hidden-files: true |
| 87 | + path: . |
| 88 | + |
0 commit comments