8282
8383 - id : matrices # TODO: build origin matrices dynamically, consider collapsing this into a .py
8484 name : Construct matrices
85+ env :
86+ PR_COMMENT_BODY : ${{ github.event.comment.body }}
8587 run : |
8688 import os
8789 import json
90+ import re
8891
8992 build_matrix = {"include": []}
9093 run_matrix = {"version": []}
@@ -168,12 +171,21 @@ jobs:
168171 ]
169172
170173 dirs_to_filter = []
174+ mc_versions = []
171175
172176 match os.getenv('GITHUB_EVENT_NAME'):
173177 case 'pull_request':
174178 if "${{ steps.filter.outcome }}" == "success":
175179 # Filter matrices based on the detected changes
176180 dirs_to_filter = json.loads('${{ steps.filter.outputs.changes }}')
181+ comment_body = os.getenv('PR_COMMENT_BODY')
182+ print("PR-comment:", comment_body)
183+ if comment_body:
184+ pattern = r'Automatic commit: build and run ([1-9\.]*[1-9]) in ([1-9_]*[1-9])'
185+ match = re.search(pattern, comment_body)
186+ if match:
187+ mc_versions = [ match.group(1) ]
188+ dirs_to_filter = [ match.group(2) ]
177189
178190 case 'workflow_dispatch':
179191 input_dirs = '${{ github.event.inputs.dirs }}'
@@ -193,8 +205,8 @@ jobs:
193205 build_matrix['include'], run_matrix['version'] = build_data, run_data
194206
195207 if dirs_to_filter:
196- build_matrix['include'].extend([item for item in build_data if item["dir"] in dirs_to_filter])
197- mc_versions = [item.get("mc") for item in build_matrix["include"] if "mc" in item]
208+ build_matrix['include'].extend([item for item in build_data if item["dir"] in dirs_to_filter and (item["mc"] in mc_versions or not mc_versions) ])
209+ mc_versions = mc_versions if mc_versions else [item.get("mc") for item in build_matrix["include"] if "mc" in item]
198210 run_matrix['version'].extend([item for item in run_data if item["mc"] in mc_versions])
199211
200212 with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
0 commit comments