Repository navigation
Expand file tree
/
Copy pathsoc-delete
More file actions
executable file
·65 lines (54 loc) · 2.33 KB
/
Copy pathsoc-delete
File metadata and controls
executable file
·65 lines (54 loc) · 2.33 KB
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
62
63
64
65
#!/usr/bin/env bash
# The 'delete' command deletes the entire GitHub organization. Depends on the
# 'user_config.sh' and 'system_config.sh' files. For organization deletion we
# need the 'admin:org' scope.
set -e
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/soc-lib.sh"
source "${SCRIPT_DIR}/soc-lib-gh.sh"
# If exist, source the configuration files
if [[ -f 'user_config.sh' && -f 'source_config.sh' && -f 'system_config.sh' ]]; then
source user_config.sh
source source_config.sh
source system_config.sh
else
echo "${WRN} The 'user_config.sh', 'source_config.sh' and/or 'system_config.sh' "
echo "file is missing. Please run the 'gh soc init' command to create the "
echo "missing file(s)."
exit 1
fi
# Silently validate global variables before all functions except 'init' and
# 'precheck'
precheck 0
# Check if the user has the required token scopes defined in the
# 'GH_TOKEN_SCOPES' in th 'system_config.sh' file. The command 'unsync'
# requires the 'delete_repo' scope for repository deletion and the 'project'
# scope for project deletion. For logging the project, we need the
# 'read:project' scope, but other commands require more permissions. For
# example, the 'project' scope is required by 'open' command to link the
# project to a team, by the 'sync' command to create the project, and the
# 'close' command to close the project. The 'open' command requires the
# 'write:org' scope, while the 'invite', 'disinvite', and 'delete' commands
# require the 'admin:org' scope.
check_if_gh_has_required_token_scopes
delete() {
# Asking the user for confirmation for deleting the organization
echo -n "${WRN} Are you sure you want to delete the organization "
echo "'${GH_ORG_NAME}'? (no/yes) [no]:"
read -r user_confirm
if [[ "${user_confirm}" == 'yes' ]]; then
# Requesting the user to type the organization name for final confirmation
echo "${WRN} Please type the name of the organization to confirm deletion: "
read -r typed_org_name
if [[ "${typed_org_name}" == "${GH_ORG_NAME}" ]]; then
echo 'Running delete_organization()'
delete_organization
else
echo -n "${WRN} The typed name '${typed_org_name}' does not match "
echo "the organization name '${GH_ORG_NAME}'. Aborting deletion."
fi
else
echo "${WRN} Deletion aborted by the user."
fi
}
delete