-
Notifications
You must be signed in to change notification settings - Fork 103
90 lines (78 loc) · 2.98 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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/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/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 }}'