Suggestion: show as error when specifying an invalid label #8115
Replies: 1 comment 1 reply
-
Hey @SubaruArai. It's not so simple as GitHub Actions allows users to create their own runners, and these runners can have arbitrary labels assigned to them. However, you can implement a custom check within your workflow to achieve a similar result. Here's a high-level approach to do this:
Here's an example workflow YAML snippet: name: Your workflow name
on:
push:
branches:
- main
jobs:
check-runner-label:
runs-on: ${{ matrix.label }}
strategy:
matrix:
label:
- ubuntu-22.04
- ubuntu-20.04
- custom-label
steps:
- name: Check Runner Label
run: |
SUPPORTED_LABELS="windows-latest windows-2022 windows-2019 ubuntu-latest ubuntu-22.04 ubuntu-20.04 macos-latest macos-latest-xl macos-13 macos-13-xl macos-12 macos-12-xl macos-11 custom-label"
if [[ ! $SUPPORTED_LABELS =~ ${{ matrix.label }} ]]; then
echo "Error: Unsupported runner label '${{ matrix.label }}'"
exit 1
fi In this example, the workflow is configured to run on different runner labels specified in the matrix strategy. It then checks if the current runner label is in the list of supported labels. If not, it displays an error message and fails the workflow. Remember to customize the list of supported labels (SUPPORTED_LABELS) according to your specific requirements. You can find a list of the labels that are backed by runners hosted by GH here: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners. Also you may set SUPPORTED_LABELS on the organization level to reduce maintenance burden. |
Beta Was this translation helpful? Give feedback.
-
When specified invalid labels, runners will just ... not run and not respond.
Can we change this behavior to an actual error message?
Bonus points if deprecated labels will be marked as deprecated.
Beta Was this translation helpful? Give feedback.
All reactions