btrfs-progs: ci: add github actions admin scripts
Add helper scripts to build static binaries manually or clean old runs. Requires the 'gh' command line tool and write access the git repository. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
475cc44e0b
commit
ae1bf6d881
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh -xe
|
||||
|
||||
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
|
||||
type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; }
|
||||
|
||||
repo="kdave/btrfs-progs"
|
||||
|
||||
for id in $(gh run -R "$repo" list -w 'Devel build and tests' -s failure --json databaseId | jq '.[].databaseId'); do
|
||||
echo "Delete run $id"
|
||||
gh run -R "$repo" delete "$id"
|
||||
done
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh -xe
|
||||
|
||||
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
|
||||
type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; }
|
||||
|
||||
repo="kdave/btrfs-progs"
|
||||
|
||||
from=3
|
||||
|
||||
for id in $(gh run -R "$repo" list -w 'CI image tests' --json databaseId | jq '.[].databaseId' | tail -n +${from}); do
|
||||
echo "Delete run $id"
|
||||
gh run -R "$repo" delete "$id"
|
||||
done
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh -xe
|
||||
|
||||
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
|
||||
type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; }
|
||||
|
||||
repo="kdave/btrfs-progs"
|
||||
|
||||
from=11
|
||||
|
||||
for id in $(gh run -R "$repo" list -w 'Devel build and tests' --json databaseId | jq '.[].databaseId' | tail -n +${from}); do
|
||||
echo "Delete run $id"
|
||||
gh run -R "$repo" delete "$id"
|
||||
done
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh -xe
|
||||
|
||||
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
|
||||
type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; }
|
||||
|
||||
repo="kdave/btrfs-progs"
|
||||
|
||||
from=3
|
||||
|
||||
for id in $(gh run -R "$repo" list -w 'Static binaries' --json databaseId | jq '.[].databaseId' | tail -n +${from}); do
|
||||
echo "Delete run $id"
|
||||
gh run -R "$repo" delete "$id"
|
||||
done
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
|
||||
type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; }
|
||||
|
||||
repo="kdave/btrfs-progs"
|
||||
|
||||
daysmax=8
|
||||
|
||||
clean_workflow() {
|
||||
local wf="$1"
|
||||
local json=$(gh run -R "$repo" list -w "$wf" --json databaseId,startedAt)
|
||||
|
||||
echo "Cleaning workflow $wf"
|
||||
i=0
|
||||
while :; do
|
||||
id=$(echo "$json" | jq -r ".[$i].databaseId")
|
||||
if [ "$id" == "null" -o -z "$id" ]; then
|
||||
break
|
||||
fi
|
||||
echo "ID: $id"
|
||||
now=$(date +%s)
|
||||
date=$(echo "$json" | jq -r ".[$i].startedAt")
|
||||
ts=$(date --date=${date} +%s)
|
||||
delta=$(($now-$ts))
|
||||
days=$(($delta/3600/24))
|
||||
echo "Started at $id, delta $delta, days $days"
|
||||
if [ "$days" -ge "$daysmax" ]; then
|
||||
echo "Delete run $id"
|
||||
gh run -R "$repo" delete "$id"
|
||||
fi
|
||||
|
||||
# loop
|
||||
i=$(($i+1))
|
||||
done
|
||||
}
|
||||
|
||||
clean_workflow "Testing CI build"
|
||||
clean_workflow "Devel build and tests"
|
||||
clean_workflow "CI image tests"
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh -ex
|
||||
# Usage: $0 tag
|
||||
#
|
||||
# Requires: gh extension 'release' installed (https://cli.github.com/manual/gh_release)
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "ERROR: needs tag where to upload the static binaries"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
|
||||
type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; }
|
||||
|
||||
repo="kdave/btrfs-progs"
|
||||
|
||||
tag="$1"
|
||||
# TODO: verify that tag exists
|
||||
|
||||
# Read last workflow id
|
||||
id=$(gh run -R "$repo" list -w 'Static binaries' -L 1 --json databaseId | jq '.[].databaseId')
|
||||
|
||||
for asset in btrfs.box.static btrfs.static; do
|
||||
gh run -R "$repo" download "$id" -n "$asset"
|
||||
chmod 755 "$asset"
|
||||
gh release -R "$repo" upload "$tag" "$asset"
|
||||
done
|
||||
|
||||
for asset in btrfs.box.static.sha256 btrfs.static.sha256; do
|
||||
gh run -R "$repo" download "$id" -n "$asset"
|
||||
gh release -R "$repo" upload "$tag" "$asset"
|
||||
done
|
Loading…
Reference in New Issue