@@ -210,46 +210,37 @@ jobs:
210210 - name : Type check with `mypy`
211211 run : mypy src
212212
213- check-for-ofm-feature-branch :
214- # This job runs only if a feature branch is specified in the merge request description.
215- # The line below looks for a line starting with `OFM Feature Branch:`. This should
216- # match the `grep` command in the step script.
213+ analyse-pr-description :
214+ # This job uses a regex to match the feature branch specified in the
215+ # PR description. If there isn't one, it should be an empty string.
217216 runs-on : ubuntu-latest
218217 outputs :
219- feature-branch : ${{ steps.determine-feature-branch .outputs.feature-branch }}
218+ feature-branch : ${{ steps.regex-match .outputs.group1 }}
220219 steps :
221- - name : Determine feature branch
222- env :
223- PULL_REQUEST_BODY : ${{ github.event.pull_request.body }}
224- # The `if:` block for this job has already checked we will have a matching line.
225- # The logic below will first extract the matching line from the PR description,
226- # then remove the prefix so we're left with only the branch name, which we check
227- # out.
220+ - name : Check the pull request body for an OFM feature branch
221+ id : regex-match
222+ uses : KyoriPowered/action-regex-match@v3
223+ with :
224+ text : ${{ github.event.pull_request.body }}
225+ regex : ' ^\s*OFM[ \-_]Feature[ \-_]Branch:\s*([\w\-]+)'
226+ flags : ' mi'
227+
228+ - name : Print the recovered branch
228229 run : |
229- matching_line=$(echo "$PULL_REQUEST_BODY" | grep "^OFM Feature Branch:")
230- regex="OFM Feature Branch: ([a-zA-Z0-9_\-]+)"
231- if [[ $matching_line =~ $regex ]]; then
232- feature_branch="${BASH_REMATCH[1]}"
233- echo "Using feature branch '$feature_branch'"
234- echo "feature-branch=$feature_branch" >> "$GITHUB_OUTPUT"
235- else
236- echo "No feature branch found."
237- echo "feature-branch=''" >> "$GITHUB_OUTPUT"
238- fi
239- id : determine-feature-branch
230+ echo "Matched string: '${{ steps.regex-match.outputs.match }}'"
231+ echo "Matched group: '${{ steps.regex-match.outputs.group1 }}'"
240232
241233 test-against-ofm-feature-branch :
242- # This job uses the feature branch found by the previous job .
243- # It is split from that job in order to allow re-use of the steps from
244- # test-against-ofm-v3
245- needs : check-for-ofm-feature-branch
246- if : ${{ needs.check-for-ofm-feature-branch .outputs.feature-branch }}
234+ # This job uses the feature branch found by `analyse-pr-description` .
235+ # If that job didn't find a feature branch, it will be an empty string
236+ # so this job won't run.
237+ needs : analyse-pr-description
238+ if : needs.analyse-pr-description .outputs.feature-branch != ''
247239 runs-on : ubuntu-latest
248240 continue-on-error : true
249241 defaults :
250242 run :
251243 working-directory : ../openflexure-microscope-server/
252244 env :
253- REF : ${{ needs.check-for-ofm-feature-branch .outputs.feature-branch }}
245+ REF : ${{ needs.analyse-pr-description .outputs.feature-branch }}
254246 steps : *test-against-ofm-steps
255-
0 commit comments