forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.63 KB
/
reusable-check-built-files.yml
File metadata and controls
110 lines (94 loc) · 3.63 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
##
# A reusable workflow that checks for uncommitted changes to built files in pull requests.
##
name: Check Built Files (PRs)
on:
workflow_call:
permissions: {}
jobs:
# Checks a PR for uncommitted changes to built files.
#
# When changes are detected, the patch is stored as an artifact for processing by the Commit Built File Changes
# workflow.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up Node.js.
# - Configures caching for Composer.
# - Installs Composer dependencies.
# - Logs general debug information about the runner.
# - Installs npm dependencies.
# - Builds CSS file using SASS.
# - Builds Emoji files.
# - Builds bundled Root Certificate files.
# - Builds WordPress.
# - Checks for changes to versioned files.
# - Displays the result of git diff for debugging purposes.
# - Saves the diff to a patch file.
# - Uploads the patch file as an artifact.
update-built-files:
name: Check and update built files
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Set up Node.js
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version-file: '.nvmrc'
cache: npm
# This date is used to ensure that the PHPCS cache is cleared at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"
# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
# passing a custom cache suffix ensures that the cache is flushed at least once per week.
- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1
with:
custom-cache-suffix: ${{ steps.get-date.outputs.date }}
- name: Log debug information
run: |
npm --version
node --version
curl --version
git --version
- name: Install npm Dependencies
run: npm ci
- name: Run SASS precommit tasks
run: npm run grunt precommit:css
- name: Run Emoji precommit task
run: npm run grunt precommit:emoji
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run certificate tasks
run: npm run grunt copy:certificates
- name: Build WordPress
run: npm run build:dev
- name: Check for changes to versioned files
id: built-file-check
run: |
if git diff --quiet; then
echo "uncommitted_changes=false" >> "$GITHUB_OUTPUT"
else
echo "uncommitted_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Display changes to versioned files
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
run: git diff
- name: Save diff to a file
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
run: git diff > ./changes.diff
# Uploads the diff file as an artifact.
- name: Upload diff file as artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
with:
name: pr-built-file-changes
path: changes.diff