@@ -210,38 +210,24 @@ 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.
228- 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
220+ - name : Check the pull request body for an OFM feature branch
221+ id : regex-match
222+ uses : actions-ecosystem/action-regex-match@v2
223+ with :
224+ text : ${{ github.event.pull_request.body }}
225+ regex : ' ^OFM Feature Branch: ([a-zA-Z0-9_\-]+)\s*'
240226
241227 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
228+ # This job uses the feature branch found by `analyse-pr-description` .
229+ # If that job didn't find a feature branch, it will be an empty string
230+ # so this job won't run.
245231 needs : check-for-ofm-feature-branch
246232 if : ${{ needs.check-for-ofm-feature-branch.outputs.feature-branch }}
247233 runs-on : ubuntu-latest
0 commit comments