Get values #25688
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
name: Get values | |
on: | |
workflow_dispatch: | |
# push: | |
schedule: | |
- cron: "*/30 * * * *" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
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@v4 | |
with: | |
fetch-depth: 1 | |
repository: armbian/scripts | |
path: scripts | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_KEY2 }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE2 }} | |
workdir: scripts | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Get info from Armbian repository | |
run: | | |
sudo wget https://apt.armbian.com/armbian.key -O key | |
sudo gpg --dearmor < key | sudo tee /usr/share/keyrings/armbian.gpg > /dev/null | |
sudo chmod go+r /usr/share/keyrings/armbian.gpg | |
RELEASE=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d"=" -f2) | |
sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/armbian.gpg] http://beta.armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" | sudo tee /etc/apt/sources.list.d/armbian.list | |
sudo apt-get update | |
CURRENT=$(apt search --names-only 'linux-image-current-x86' 2> /dev/null | grep Armbian | grep -oE "(\w*[.]\w*)*" | head -1) | |
EDGE=$(apt search --names-only 'linux-image-edge-x86' 2> /dev/null | grep Armbian | grep -oE "(\w*[.]\w*)*" | head -1) | |
echo "CURRENT=${CURRENT}" >> $GITHUB_ENV | |
echo "EDGE=${EDGE}" >> $GITHUB_ENV | |
- name: Get runners capacity | |
run: | | |
echo "ABc= $CURRENT $EDGE" | |
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 | |
# add kernel versions to JSON | |
jq '.CURRENT += "'${{ env.CURRENT }}'"' runners_capacity.json > tmp_current.json | |
jq '.EDGE += "'${{ env.EDGE }}'"' tmp_current.json > tmp_edge.json | |
cp tmp_edge.json runners_capacity.json | |
cat runners_capacity.json | |
# add smoke test success | |
#gh run download --name status --repo github.com/armbian/scripts | |
#jq '.SMOKE += "'$(cat success)'%"' runners_capacity.json > tmp.json | |
#cp tmp.json 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 "[email protected]" | |
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 |