Skip to content

feat(runs-on-selector): add runs-on selector action #57

feat(runs-on-selector): add runs-on selector action

feat(runs-on-selector): add runs-on selector action #57

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
permissions: {}
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# The repository picks its own runner with the action it ships, so a change to
# that action is exercised by the pull request that makes the change.
runner:
name: Runner
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
outputs:
runs-on: ${{ steps.pick.outputs.runs-on }}
steps:
# Only because `uses: ./actions/runs-on-selector` reads the action itself
# from the workspace. A consumer of the published action needs no
# checkout, because the map is an input.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
sparse-checkout: actions/runs-on-selector
sparse-checkout-cone-mode: false
- id: pick
uses: ./actions/runs-on-selector
with:
default: github
pools-json: |
{
"github": "ubuntu-24.04",
"blacksmith": "blacksmith-2vcpu-ubuntu-2404"
}
check:
name: Lint
needs: runner
runs-on: ${{ needs.runner.outputs.runs-on }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Tool versions live in mise.toml and the task lives under
# .config/mise/tasks, so a contributor runs exactly what CI runs.
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
- run: mise run github:actions:ci:lint
test:
name: Test
needs: runner
runs-on: ${{ needs.runner.outputs.runs-on }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
- run: mise run github:actions:tests:node
# The `Runner` job above already proves `pools-json` arrives and the
# output reads back. This covers the rest. `label-prefix` is a dashed
# input name, so the runner spells it INPUT_LABEL-PREFIX, and a unit test
# here can only assert the same guess the code was written from.
- id: contract
uses: ./actions/runs-on-selector
with:
default: github
label-prefix: action-runner
label: action-runner:blacksmith
pools-json: '{"github":"ubuntu-24.04","blacksmith":"blacksmith-2vcpu-ubuntu-2404"}'
- env:
RUNS_ON: ${{ steps.contract.outputs.runs-on }}
run: '[ "$RUNS_ON" = "blacksmith-2vcpu-ubuntu-2404" ]'