Skip to content

Commit

Permalink
Testing runners uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
vmilosevic committed Aug 16, 2024
1 parent 27527c1 commit 17bd748
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: On PR

on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

jobs:
pre-commit:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: On push

on:
workflow_dispatch:
push:
branches: [ "main" ]
# push:
# branches: [ "main" ]

jobs:
pre-commit:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/ttrt-collect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Collect Uptime from Runners

on:
push:

jobs:
get-runners:
runs-on: ubuntu-latest
outputs:
runners: ${{ steps.get-runners.outputs.runners }}
steps:
- name: Get Self-Hosted Runners
id: get-runners
run: |
echo "Fetching self-hosted runners..."
runners=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/runners" | \
jq -r '.runners[] | select(.status=="online") | .name')
echo "::set-output name=runners::$(echo $runners | tr '\n' ',')"
run-uptime:
needs: get-runners
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: ${{ fromJson(needs.get-runners.outputs.runners) }}
steps:
- name: Run Uptime Command
run: |
uptime > uptime.txt
echo "Runner: ${{ matrix.runner }}" >> uptime.txt
- name: Upload Uptime Artifact
uses: actions/upload-artifact@v2
with:
name: uptime-${{ matrix.runner }}
path: uptime.txt

combine-artifacts:
needs: run-uptime
runs-on: ubuntu-latest
steps:
- name: Download Uptime Artifacts
uses: actions/download-artifact@v2
with:
name: uptime-*
path: ./artifacts

- name: Combine Artifacts into CSV
run: |
echo "Runner Name,Uptime" > uptime_report.csv
for file in ./artifacts/*; do
runner_name=$(basename "$file" | sed 's/^uptime-//')
uptime=$(cat "$file")
echo "$runner_name,$uptime" >> uptime_report.csv
done
- name: Upload Combined CSV
uses: actions/upload-artifact@v2
with:
name: uptime-report
path: uptime_report.csv

0 comments on commit 17bd748

Please sign in to comment.