1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!/bin/bash
# Manually runs the nightly workflow when sent.
# Pass in -t <personalAPItoken> -r <releasetype, (nightly, prerelease, release)> -g <github repo name e.g. (naev/naev)>
set -e
# Defaults
REPO="naev/naev"
while getopts d:t:r:g: OPTION "$@"; do
case $OPTION in
d)
set -x
;;
t)
TOKEN="${OPTARG}"
;;
r)
RELEASETYPE="${OPTARG}"
;;
g)
REPO="${OPTARG}"
;;
esac
done
if [[ -z "$TOKEN" ]]; then
echo "usage: `basename $0` [-d] -t <personalAPItoken> -r <releasetype, (nightly, prerelease, release)>"
exit 1
elif [[ -z "$RELEASETYPE" ]]; then
echo "usage: `basename $0` [-d] -t <personalAPItoken> -r <releasetype, (nightly, prerelease, release)>"
exit 1
fi
if [[ "$RELEASETYPE" == "nightly" ]]; then
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $TOKEN" \
https://api.github.com/repos/"$REPO"/dispatches \
-d '{"event_type":"manual-nightly"}'
elif [[ "$RELEASETYPE" == "prerelease" ]]; then
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $TOKEN" \
https://api.github.com/repos/"$REPO"/dispatches \
-d '{"event_type":"manual-prerelease"}'
elif [[ "$RELEASETYPE" == "release" ]]; then
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $TOKEN" \
https://api.github.com/repos/"$REPO"/dispatches \
-d '{"event_type":"manual-release"}'
else
echo "-r must be either nightly, prerelease or release"
exit 1
fi
|