File: manuallyTriggerWorkflow.sh

package info (click to toggle)
naev 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 386,084 kB
  • sloc: ansic: 93,149; xml: 87,292; python: 2,347; sh: 904; makefile: 654; lisp: 162; awk: 4
file content (61 lines) | stat: -rwxr-xr-x 1,607 bytes parent folder | download | duplicates (2)
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