-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27527c1
commit 17bd748
Showing
3 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |