Moved build process to one that automatically picks a local runner if available, re-enabled automatic building
This commit is contained in:
1 parent
13964979af
commit
7b9eb6d0fd
2 files changed
+35
-64
No files matched your search
@@ -1,6 +1,8 @@
|
||||
name: Build & Publish to GHCR
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
@@ -13,8 +15,40 @@ env:
|
||||
OPS_PATH: backend-pull-notifications/deployment.yaml
|
||||
|
||||
jobs:
|
||||
build:
|
||||
select-runner:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
runner: ${{ steps.pick.outputs.runner }}
|
||||
steps:
|
||||
- name: Check if local runner is online
|
||||
id: pick
|
||||
env:
|
||||
API_TOKEN: ${{ secrets.GET_AVAILABLE_RUNNERS_API_TOKEN }}
|
||||
API_URL: ${{ github.server_url }}/api/v1/admin/actions/runners
|
||||
run: |
|
||||
RUNNER="ubuntu-latest"
|
||||
|
||||
RESPONSE=$(curl -fsS --max-time 15 \
|
||||
-H "Authorization: token ${API_TOKEN}" \
|
||||
"${API_URL}" || echo "")
|
||||
|
||||
if [ -n "$RESPONSE" ]; then
|
||||
ONLINE=$(echo "$RESPONSE" | jq '[.runners[]?
|
||||
| select(.status != "offline")
|
||||
| select(any(.labels[]?; .name == "local"))] | length')
|
||||
if [ "${ONLINE:-0}" -gt 0 ]; then
|
||||
RUNNER="local"
|
||||
fi
|
||||
else
|
||||
echo "Runner API not reachable, falling back to ubuntu-latest"
|
||||
fi
|
||||
|
||||
echo "Selected runner: $RUNNER"
|
||||
echo "runner=$RUNNER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: select-runner
|
||||
runs-on: ${{ needs.select-runner.outputs.runner }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
Reference in new issue
Block a user