@@ -23,92 +23,20 @@ permissions: {}
2323
2424jobs :
2525 # Detects whether the gutenberg.sha value in the package.json file has changed.
26- #
27- # Performs the following steps:
28- # - Checks out the repository.
29- # - Check if the pinned hash has changed.
3026 detect-hash-change :
3127 name : Detect Gutenberg SHA change
32- runs-on : ubuntu-24.04
33- if : ${{ github.repository == 'wordpress/wordpress-develop' }}
28+ uses : ./.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml
3429 permissions :
3530 contents : read
36- outputs :
37- sha_changed : ${{ steps.check-sha.outputs.sha_changed }}
38- base_sha : ${{ steps.check-sha.outputs.base_sha }}
39- head_sha : ${{ steps.check-sha.outputs.head_sha }}
40-
41- steps :
42- - name : Checkout repository
43- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
44- with :
45- fetch-depth : 0
46- persist-credentials : false
47-
48- - name : Check if the pinned Gutenberg hash has changed
49- id : check-sha
50- run : |
51- BASE_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.base.sha }}:package.json | jq -r '.gutenberg.sha // empty')
52- HEAD_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.head.sha }}:package.json | jq -r '.gutenberg.sha // empty')
53-
54- echo "base_sha=$BASE_GUTENBERG_SHA" >> "$GITHUB_OUTPUT"
55- echo "head_sha=$HEAD_GUTENBERG_SHA" >> "$GITHUB_OUTPUT"
56-
57- if [ "$BASE_GUTENBERG_SHA" != "$HEAD_GUTENBERG_SHA" ]; then
58- echo "sha_changed=true" >> "$GITHUB_OUTPUT"
59- echo "The pinned Gutenberg Repository hash has changed."
60- echo " Previous SHA (base branch): $BASE_GUTENBERG_SHA"
61- echo " New SHA (head branch): $HEAD_GUTENBERG_SHA"
62- else
63- echo "sha_changed=false" >> "$GITHUB_OUTPUT"
64- echo "The pinned Gutenberg repository hash has not changed: $HEAD_GUTENBERG_SHA"
65- fi
6631
6732 # Generates a list of changes between two specified hashes.
68- #
69- # Performs the following steps:
70- # - Checks out the repository.
71- # - Generates a list of changes.
72- # - Uploads the changelog as an artifact.
7333 generate-changelog :
7434 name : Generate a list of changes between the hashes
75- runs-on : ubuntu-24.04
35+ uses : ./.github/workflows/reusable-generate-gutenberg-changelog-v1.yml
7636 needs : [ 'detect-hash-change' ]
7737 if : ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }}
7838 permissions :
7939 contents : read
80- outputs :
81- has_changes : ${{ steps.change-list.outputs.has_changes }}
82-
83- steps :
84- - name : Checkout Gutenberg repository
85- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
86- with :
87- repository : WordPress/gutenberg
88- filter : blob:none
89- fetch-depth : 0
90-
91- - name : Generate a list of changes
92- id : change-list
93- env :
94- BASE_SHA : ${{ needs.detect-hash-change.outputs.base_sha }}
95- HEAD_SHA : ${{ needs.detect-hash-change.outputs.head_sha }}
96- run : |
97- git log --reverse --format="- %s" "$BASE_SHA".."$HEAD_SHA" | \
98- sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' \
99- > changelog.txt
100-
101- if [ -s changelog.txt ]; then
102- echo "has_changes=true" >> "$GITHUB_OUTPUT"
103- else
104- echo "has_changes=false" >> "$GITHUB_OUTPUT"
105- fi
106-
107- - name : Upload changelog as an artifact
108- uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
109- with :
110- path : changelog.txt
111- archive : false
11240
11341 # Drafts a commit message containing a detailed list of changes being merged.
11442 #
@@ -118,53 +46,11 @@ jobs:
11846 # - Uploads the commit message as an artifact.
11947 generate-commit-message :
12048 name : Generate commit message
121- runs-on : ubuntu-24.04
49+ uses : ./.github/workflows/reusable-generate-commit-message-v1.yml
12250 needs : [ 'detect-hash-change', 'generate-changelog' ]
123- if : ${{ needs.detect-hash-change .outputs.sha_changed == 'true' }}
51+ if : ${{ needs.generate-changelog .outputs.has_changes == 'true' }}
12452 permissions :
12553 contents : read
126-
127- steps :
128- - name : Download changelog artifact
129- if : ${{ needs.generate-changelog.outputs.has_changes == 'true' }}
130- uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
131- with :
132- name : changelog.txt
133- skip-decompress : true
134-
135- - name : Build commit message
136- env :
137- BASE_SHA : ${{ needs.detect-hash-change.outputs.base_sha }}
138- HEAD_SHA : ${{ needs.detect-hash-change.outputs.head_sha }}
139- HAS_CHANGES : ${{ needs.generate-changelog.outputs.has_changes }}
140- run : |
141- {
142- printf 'Editor: Bump pinned hash for the Gutenberg repository.\n\n'
143- printf "This updates the pinned hash from the gutenberg from \`%s\` to \`%s\`.\n\n" "$BASE_SHA" "$HEAD_SHA"
144-
145- if [ "$HAS_CHANGES" = "false" ]; then
146- printf '> [!WARNING]\n'
147- printf '> No pull request references were found in the commits between the two hashes. Please verify the hash range is correct.\n\n'
148- else
149- printf 'The following changes are included:\n\n'
150- cat changelog.txt
151- printf '\n'
152- fi
153-
154- printf 'A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/%s...%s.\n\n' "$BASE_SHA" "$HEAD_SHA"
155- printf 'See #64595, #64393.\n'
156- } > commit-message.md
157-
158- - name : Upload commit message as an artifact
159- uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
160- with :
161- path : commit-message.md
162- archive : false
163-
164- - name : Post PR comment
165- env :
166- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
167- PR_NUMBER : ${{ github.event.pull_request.number }}
168- REPO : ${{ github.repository }}
169- run : |
170- gh pr comment "$PR_NUMBER" --body-file commit-message.md --repo "$REPO"
54+ with :
55+ previous-hash : ${{ needs.detect-hash-change.outputs.base_sha }}
56+ new-hash : ${{ needs.detect-hash-change.outputs.head_sha }}
0 commit comments