@@ -59,6 +59,22 @@ module.exports = function(grunt) {
5959 '!wp-includes/assets/script-modules-packages.min.php' ,
6060 ] ,
6161
62+ // All workflow files that should be deleted from non-default branches.
63+ workflowFiles = [
64+ // Reusable workflows should be called from `trunk` within branches.
65+ '.github/workflows/reusable-*.yml' ,
66+ // These workflows are only intended to run from `trunk`.
67+ '.github/workflows/commit-built-file-changes.yml' ,
68+ '.github/workflows/failed-workflow.yml' ,
69+ '.github/workflows/install-testing.yml' ,
70+ '.github/workflows/test-and-zip-default-themes.yml' ,
71+ '.github/workflows/install-testing.yml' ,
72+ '.github/workflows/slack-notifications.yml' ,
73+ '.github/workflows/test-coverage.yml' ,
74+ '.github/workflows/test-old-branches.yml' ,
75+ '.github/workflows/upgrade-testing.yml'
76+ ] ,
77+
6278 // Prepend `dir` to `file`, and keep `!` in place.
6379 setFilePath = function ( dir , file ) {
6480 if ( '!' === file . charAt ( 0 ) ) {
@@ -216,7 +232,18 @@ module.exports = function(grunt) {
216232 cwd : WORKING_DIR ,
217233 src : [ ]
218234 } ,
219- qunit : [ 'tests/qunit/compiled.html' ]
235+ qunit : [ 'tests/qunit/compiled.html' ] ,
236+
237+ // This is only meant to run within a numbered branch after branching has occurred.
238+ workflows : {
239+ filter : function ( ) {
240+ var allowedTasks = [ 'post-branching' , 'clean:workflows' ] ;
241+ return allowedTasks . some ( function ( task ) {
242+ return grunt . cli . tasks . indexOf ( task ) !== - 1 ;
243+ } ) ;
244+ } ,
245+ src : workflowFiles
246+ } ,
220247 } ,
221248 file_append : {
222249 // grunt-file-append supports only strings for input and output.
@@ -1708,6 +1735,11 @@ module.exports = function(grunt) {
17081735 'copy:workflow-references-remote-to-local' ,
17091736 ] ) ;
17101737
1738+ grunt . registerTask ( 'post-branching' , [
1739+ 'clean:workflows' ,
1740+ 'replace:workflow-references-local-to-remote'
1741+ ] ) ;
1742+
17111743 /**
17121744 * Build verification tasks.
17131745 */
0 commit comments