Skip to content

Update 01-content-development-general.md #434

Update 01-content-development-general.md

Update 01-content-development-general.md #434

Workflow file for this run

name: Build and push to build branch.
on:
push:
branches: [trunk]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: trunk
- name: Install NodeJS
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
with:
node-version-file: ".nvmrc"
cache: "yarn"
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2.25.4
with:
php-version: "7.4"
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install php dependencies
shell: bash
run: |
composer install || composer update wporg/*
- name: Git reset and clean
run: |
git reset --hard
git clean -f -d
- name: Setup configs
shell: bash
run: |
yarn setup:tools
- name: yarn install and build
run: |
yarn
yarn workspaces run build
- name: Trim the repo down to just the source and built files
run: |
rm -rf wp-content/mu-plugins/pub/locale-switcher/node_modules
rm -rf wp-content/plugins/wporg-learn/node_modules
rm -rf wp-content/themes/pub/wporg-learn-2024/node_modules
mv wp-content/mu-plugins/pub/locale-switcher $RUNNER_TEMP
mv wp-content/mu-plugins/pub/class-validator.php $RUNNER_TEMP
mv wp-content/mu-plugins/pub/locales.php $RUNNER_TEMP
mv wp-content/mu-plugins/pub/wporg-learn-cli.php $RUNNER_TEMP
mv wp-content/plugins/polylang-pro $RUNNER_TEMP
mv wp-content/plugins/sensei-pro $RUNNER_TEMP
mv wp-content/plugins/wporg-learn $RUNNER_TEMP
mv wp-content/themes/pub/wporg-learn-2024 $RUNNER_TEMP
git rm -rfq .
rm -rf *
mkdir -p wp-content/mu-plugins/pub
mkdir -p wp-content/plugins
mkdir -p wp-content/themes/pub
mv $RUNNER_TEMP/locale-switcher wp-content/mu-plugins/pub
mv $RUNNER_TEMP/class-validator.php wp-content/mu-plugins/pub
mv $RUNNER_TEMP/locales.php wp-content/mu-plugins/pub
mv $RUNNER_TEMP/wporg-learn-cli.php wp-content/mu-plugins/pub
mv $RUNNER_TEMP/polylang-pro wp-content/plugins
mv $RUNNER_TEMP/sensei-pro wp-content/plugins
mv $RUNNER_TEMP/wporg-learn wp-content/plugins
mv $RUNNER_TEMP/wporg-learn-2024 wp-content/themes/pub
- name: Add all the files
run: |
git add * --force
- name: Append build number to version
run: |
current_version=$(grep -oP 'Version: \K[0-9]+\.[0-9]+\.[0-9]+' wp-content/themes/pub/wporg-learn-2024/style.css)
new_version="${current_version}-${GITHUB_SHA::7}"
sed -i "s/Version: $current_version/Version: $new_version/" wp-content/themes/pub/wporg-learn-2024/style.css
- name: Commit and push
uses: actions-js/push@a52398fac807b0c1e5f1492c969b477c8560a0ba # 1.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: build
force: true
message: 'Build: ${{ github.sha }}'