|
| 1 | +name: Build WordPress |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +# Cancels all previous workflow runs for pull requests that have not completed. |
| 8 | +concurrency: |
| 9 | + # The concurrency group contains the workflow name and the branch name for pull requests |
| 10 | + # or the commit hash for any other events. |
| 11 | + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +# Disable permissions for all available scopes by default. |
| 15 | +# Any needed permissions should be configured at the job level. |
| 16 | +permissions: {} |
| 17 | + |
| 18 | +# Exposes WordPress builds as a GitHub artifact to enable |
| 19 | +# previewing Pull Requests inside WordPress Playground. |
| 20 | +# |
| 21 | +# @see https://github.com/WordPress/wordpress-playground/pull/700 |
| 22 | +# @see https://github.com/WordPress/wordpress-develop/pull/5481 |
| 23 | +jobs: |
| 24 | + build-wordpress: |
| 25 | + name: Upload WordPress build as an artifact |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + timeout-minutes: 20 |
| 30 | + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 |
| 35 | + with: |
| 36 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 37 | + |
| 38 | + - name: Set up Node.js |
| 39 | + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 |
| 40 | + with: |
| 41 | + node-version-file: '.nvmrc' |
| 42 | + cache: npm |
| 43 | + |
| 44 | + - name: Log debug information |
| 45 | + run: | |
| 46 | + npm --version |
| 47 | + node --version |
| 48 | + curl --version |
| 49 | + git --version |
| 50 | + svn --version |
| 51 | +
|
| 52 | + - name: Install npm Dependencies |
| 53 | + run: npm ci |
| 54 | + |
| 55 | + - name: Build WordPress |
| 56 | + run: npm run build |
| 57 | + |
| 58 | + - name: Zip WordPress build |
| 59 | + run: cd build && zip -r wordpress.zip . |
| 60 | + |
| 61 | + - name: Upload the build directory as GitHub artifact |
| 62 | + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 |
| 63 | + if: always() |
| 64 | + with: |
| 65 | + name: wordpress-build-${{ github.event_name == 'pull_request' && github.event.number || github.sha }} |
| 66 | + path: build/wordpress.zip |
| 67 | + if-no-files-found: error |
0 commit comments