mirror of
https://github.com/armbian/scripts.git
synced 2026-01-06 10:32:48 -08:00
88 lines
3.4 KiB
YAML
88 lines
3.4 KiB
YAML
name: Get values
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
schedule:
|
|
- cron: "*/30 * * * *"
|
|
|
|
jobs:
|
|
|
|
Prepare:
|
|
runs-on: ubuntu-latest
|
|
name: Enable test system
|
|
outputs:
|
|
matrix: ${{steps.list_dirs.outputs.matrix}}
|
|
steps:
|
|
|
|
- name: Checkout Armbian support scripts
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 1
|
|
repository: armbian/scripts
|
|
path: scripts
|
|
|
|
- name: Import GPG key
|
|
uses: crazy-max/ghaction-import-gpg@v5
|
|
with:
|
|
gpg_private_key: ${{ secrets.GPG_KEY2 }}
|
|
passphrase: ${{ secrets.GPG_PASSPHRASE2 }}
|
|
workdir: scripts
|
|
git_user_signingkey: true
|
|
git_commit_gpgsign: true
|
|
|
|
- name: Get runners capacity
|
|
run: |
|
|
|
|
sudo apt-get -y install datamash
|
|
LIST=$(curl -H "Authorization: Token ${{ secrets.NETBOX_TOKEN }}" -H "Accept: application/json; indent=4" \
|
|
"https://stuff.armbian.com/netbox/api/virtualization/virtual-machines/?limit=500&name__empty=false&tag=github-runner" \
|
|
| jq -r '.results[] | .display, .vcpus, .memory, .cluster.name, .tenant.name' | sed -e 's/^\|$/"/g' \
|
|
| xargs -n5 -d'\n' | sed -e 's/\" \"/\",\"/g' | tr -d '"' | sed "s/,/\t/g" | datamash --sort -g 4 sum 2,3 --output-delimiter=,)
|
|
(echo "CPU|MEM";
|
|
echo "$LIST" | sed "s/,/\t/g" | datamash --sort sum 2,3 | sed "s/\t/|/g") | jq -Rn '
|
|
( input | split("|") ) as $keys |
|
|
( inputs | split("|") ) as $vals |
|
|
[[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries
|
|
' > runners_capacity.json
|
|
|
|
cat runners_capacity.json
|
|
|
|
echo "|Donated by | Virtual CPU cores |Memory |" > label.tmp
|
|
echo "|--|--:|--:|" >> label.tmp
|
|
curl -H "Authorization: Token ${{ secrets.NETBOX_TOKEN }}" -H "Accept: application/json; indent=4" \
|
|
"https://stuff.armbian.com/netbox/api/virtualization/virtual-machines/?limit=500&name__empty=false&tag=github-runner" \
|
|
| jq -r '.results[] | .display, .vcpus, .memory, .cluster.name, .tenant.name' | sed -e 's/^\|$/"/g' \
|
|
| xargs -n5 -d'\n' | sed -e 's/\" \"/\",\"/g' | tr -d '"' | sed "s/,/\t/g" | datamash --sort -g 5 sum 2,3 --output-delimiter=, \
|
|
| LC_ALL=C awk -F , -v OFS=\| '$3/=1024' | cut -d"." -f1 | sed -e 's/$/ Gb/g' | sed -e 's/^\|$/|/g' >> label.tmp
|
|
|
|
# header and footer are edited at GitHub
|
|
cat scripts/.github/header.inc > scripts/README.md
|
|
echo -en "\n\n" >> scripts/README.md
|
|
cat label.tmp >> scripts/README.md
|
|
cat scripts/.github/footer.inc >> scripts/README.md
|
|
|
|
- name: "Upload status"
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
artifacts: "runners_capacity.json"
|
|
tag: "status"
|
|
omitBody: true
|
|
omitName: true
|
|
allowUpdates: true
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Update scripts
|
|
run: |
|
|
|
|
cd scripts
|
|
sudo chown -R $USER:$USER .git
|
|
if git status --porcelain | grep .; then
|
|
git config --global user.email "info@armbian.com"
|
|
git config --global user.name "Armbianworker"
|
|
git config pull.rebase false
|
|
git pull
|
|
git add .
|
|
git commit --allow-empty -m "Update runners status"
|
|
git push
|
|
fi
|