mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-05-29 11:11:41 -04:00
gh-action: test auto-choose runner
This commit is contained in:
19
.github/workflows/go-test.yml
vendored
19
.github/workflows/go-test.yml
vendored
@@ -3,8 +3,25 @@ name: go test
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
check-runner:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
runner-label: ${{ steps.set-runner.outputs.runner-label }}
|
||||
|
||||
steps:
|
||||
- name: Set runner
|
||||
id: set-runner
|
||||
run: |
|
||||
runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners")
|
||||
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
|
||||
if [ -n "$available" ]; then
|
||||
echo "runner-label=self-hosted" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build:
|
||||
runs-on: ${{ needs.check-runner.outputs.runner-label }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
||||
Reference in New Issue
Block a user