-
Notifications
You must be signed in to change notification settings - Fork 42
49 lines (44 loc) · 1.82 KB
/
determine-workflow-runner.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Determine Workflow Runner group
on:
workflow_call:
inputs:
default_runner:
description: The runner type that is used by the calling workflow by default
required: true
type: string
outputs:
runner_group:
description: The runner all subsequent jobs within the calling workflow should run on
value: ${{ jobs.determine_workflow_runner.outputs.runner_group || inputs.default_runner }}
env:
LARGE_RUNNER_GROUP_NAME: pl-4-core-large-runner
jobs:
determine_workflow_runner:
runs-on: >-
${{
(
github.event_name == 'pull_request'
&& contains(github.event.pull_request.labels.*.name, 'urgent')
) && 'pl-4-core-large-runner' || 'ubuntu-latest'
}}
outputs:
runner_group: ${{ steps.runner_group.outputs.runner_group }}
steps:
- name: Output Runner Group name
if: >-
${{
github.event_name == 'pull_request'
&& startsWith(inputs.default_runner, 'ubuntu')
}}
id: runner_group
env:
# We are not able to use \d to check numeric values as bash does not allow them (not POSIX compliant)
RC_BRANCH_FORMAT_REGEX: v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]?
REPO_FULL_NAME: PennyLaneAI/pennylane-lightning
run: |
if [[ '${{ contains(github.event.pull_request.labels.*.name, 'urgent') }}' == 'true' || ('${{ github.event.pull_request.head.repo.full_name }}' == "$REPO_FULL_NAME" && '${{ github.event.pull_request.head.ref }}' =~ $RC_BRANCH_FORMAT_REGEX) ]]; then
echo "This job requires usage of the large runner group '$LARGE_RUNNER_GROUP_NAME'";
echo "runner_group=$LARGE_RUNNER_GROUP_NAME" >> $GITHUB_OUTPUT
else
echo "This job does not require usage of large runners ...";
fi