Refresh WordPress Major&Beta #50689
This file contains hidden or 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: 'Refresh WordPress Major&Beta' | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| force_rebuild: | |
| description: 'Force rebuild of WordPress (true/false)' | |
| required: false | |
| default: 'false' | |
| # Every 20 minutes | |
| schedule: | |
| - cron: '*/20 * * * *' | |
| concurrency: | |
| group: refresh-wordpress-major-and-beta | |
| # Disable permissions for all available scopes by default. | |
| # Any needed permissions should be configured at the job level. | |
| permissions: {} | |
| jobs: | |
| build_wordpress_major_and_beta_push_to_github_and_deploy_website: | |
| # Only run this workflow on the playground repo, from the trunk branch, and when triggered by a Playground maintainer | |
| if: > | |
| github.repository == 'WordPress/wordpress-playground' && | |
| github.ref == 'refs/heads/trunk' && ( | |
| github.actor == 'adamziel' || | |
| github.actor == 'dmsnell' || | |
| github.actor == 'bgrgicak' || | |
| github.actor == 'brandonpayton' || | |
| github.actor == 'zaerl' || | |
| github.actor == 'janjakes' || | |
| github.actor == 'mho22' || | |
| github.actor == 'ashfame' | |
| ) | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: wordpress-assets | |
| # Be conservative and set _some_ timeout to prevent a hanging | |
| # job from blocking the queue of scheduled runs. | |
| timeout-minutes: 120 | |
| permissions: | |
| contents: write # Required to clone the repo and push the rebuilt WordPress commit. | |
| actions: write # Required to trigger the deploy-website workflow via workflow_dispatch. | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| clean: true | |
| persist-credentials: true | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| submodules: true | |
| - uses: ./.github/actions/prepare-playground | |
| with: | |
| # The build uses JSPI which is supported in Node.js 23+. | |
| # Let's pick 24 as an LTS release. | |
| node-version: 24 | |
| - name: 'Recompile WordPress' | |
| id: build | |
| shell: bash | |
| env: | |
| FORCE_REBUILD: ${{ github.event.inputs.force_rebuild }} | |
| run: npx nx bundle-wordpress:major-and-beta playground-wordpress-builds | |
| - name: Check for uncommitted changes | |
| id: changes | |
| run: | | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "No changes" | |
| echo 'COMMIT_CHANGES=0' >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected" | |
| echo 'COMMIT_CHANGES=1' >> $GITHUB_OUTPUT | |
| fi | |
| - name: Push rebuilt WordPress to GitHub | |
| if: steps.changes.outputs.COMMIT_CHANGES == '1' | |
| run: | | |
| # This appears to be necessary because we encountered the build output being owned by root, | |
| # and there are some subdirectories that the runner user cannot access. | |
| sudo chown -R "$(whoami):$(id -gn)" packages/playground/wordpress-builds/public | |
| git config --global user.name "deployment_bot" | |
| git config --global user.email "deployment_bot@users.noreply.github.com" | |
| git add -A | |
| git commit -a -m "Recompile WordPress major and beta versions" | |
| git pull --rebase | |
| # Push if the pull did not result in a conflict | |
| if [ $? -eq 0 ]; then | |
| git push | |
| fi; | |
| - name: Deploy website | |
| if: steps.changes.outputs.COMMIT_CHANGES == '1' | |
| uses: benc-uk/workflow-dispatch@v1 | |
| with: | |
| workflow: deploy-website.yml | |
| token: ${{ secrets.GITHUB_TOKEN }} |