@@ -102,11 +102,6 @@ jobs:
102102 cd wordpress/wp-content/plugins/accessibility-checker
103103 wp i18n make-pot . ./languages/accessibility-checker.pot --allow-root
104104
105- - name : Generate JSON files
106- run : |
107- cd wordpress/wp-content/plugins/accessibility-checker
108- wp i18n make-json ./languages ./languages --no-purge --pretty-print --allow-root
109-
110105 - name : Check if POT file changed (ignoring some headers)
111106 id : pot_diff
112107 run : |
@@ -123,66 +118,44 @@ jobs:
123118 echo "pot_changed=true" >> $GITHUB_OUTPUT
124119 fi
125120
126- - name : Check if JSON files changed
127- id : json_diff
128- run : |
129- json_changed=false
130- for file in wordpress/wp-content/plugins/accessibility-checker/languages/*.json; do
131- base_file="dist/accessibility-checker/languages/$(basename $file)"
132- if [ -f "$base_file" ]; then
133- diff_output=$(diff <(grep -vE '^#|^$' "$file") <(grep -vE '^#|^$' "$base_file") || true)
134- if [ -n "$diff_output" ]; then
135- json_changed=true
136- break
137- fi
138- else
139- json_changed=true
140- break
141- fi
142- done
143- echo "json_changed=$json_changed" >> $GITHUB_OUTPUT
144-
145121 - name : Comment on PR if POT file changed
146- if : ( steps.pot_diff.outputs.pot_changed == 'true' || steps.json_diff.outputs.json_changed == 'true') && github.event.pull_request
122+ if : steps.pot_diff.outputs.pot_changed == 'true' && github.event.pull_request
147123 uses : actions/github-script@v7
148124 with :
149125 script : |
150126 github.rest.issues.createComment({
151127 issue_number: context.issue.number,
152128 owner: context.repo.owner,
153129 repo: context.repo.repo,
154- body: 'The POT or JSON translation files have changed. Please update the translation files in your PR to keep translations up to date.\nThe updated files are available in the artifacts of this workflow run: https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + process.env.GITHUB_RUN_ID
130+ body: 'The POT translation file has changed. Please update the POT file in your PR to keep translations up to date.\nThe updated file is available in the artifacts of this workflow run: https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + process.env.GITHUB_RUN_ID
155131 })
156132
157- - name : Upload POT and JSON files as artifact
158- if : steps.pot_diff.outputs.pot_changed == 'true' || steps.json_diff.outputs.json_changed == 'true'
133+ - name : Upload POT file as artifact
134+ if : steps.pot_diff.outputs.pot_changed == 'true'
159135 uses : actions/upload-artifact@v4
160136 with :
161137 name : accessibility-checker-i18n
162- path : |
163- wordpress/wp-content/plugins/accessibility-checker/languages/accessibility-checker.pot
164- wordpress/wp-content/plugins/accessibility-checker/languages/*.json
138+ path : wordpress/wp-content/plugins/accessibility-checker/languages/accessibility-checker.pot
165139
166140 - name : Set up Git for PR
167- if : steps.pot_diff.outputs.pot_changed == 'true' || steps.json_diff.outputs.json_changed == 'true'
141+ if : steps.pot_diff.outputs.pot_changed == 'true'
168142 run : |
169143 git config --global user.name "github-actions[bot]"
170144 git config --global user.email "github-actions[bot]@users.noreply.github.com"
171145
172- - name : Replace root languages folder with built one
173- if : steps.pot_diff.outputs.pot_changed == 'true' || steps.json_diff.outputs.json_changed == 'true'
146+ - name : Copy updated POT file to languages folder
147+ if : steps.pot_diff.outputs.pot_changed == 'true'
174148 run : |
175- rm -rf languages
176- cp -r wordpress/wp-content/plugins/accessibility-checker/languages ./languages
149+ cp wordpress/wp-content/plugins/accessibility-checker/languages/accessibility-checker.pot ./languages/accessibility-checker.pot
177150
178- - name : Create or Update Pull Request with updated translations
179- if : steps.pot_diff.outputs.pot_changed == 'true' || steps.json_diff.outputs.json_changed == 'true'
151+ - name : Create or Update Pull Request with updated POT file
152+ if : steps.pot_diff.outputs.pot_changed == 'true'
180153 uses : peter-evans/create-pull-request@v6
181154 with :
182- add-paths : ./languages
183- commit-message : Update translation files (POT/JSON)
184- title : Update translation files (POT/JSON)
185- body : This PR updates the translation files (POT/JSON) generated by the workflow.
155+ add-paths : ./languages/accessibility-checker.pot
156+ commit-message : Update POT translation file
157+ title : Update POT translation file
158+ body : This PR updates the POT translation file generated by the workflow.
186159 branch : update-translations/${{ github.head_ref || github.ref_name }}
187160 base : ${{ github.event.inputs.base || github.head_ref || github.ref_name }}
188161 delete-branch : true
0 commit comments