Repository navigation
Expand file tree
/
Copy pathsoc-close
More file actions
executable file
·72 lines (58 loc) · 2.46 KB
/
Copy pathsoc-close
File metadata and controls
executable file
·72 lines (58 loc) · 2.46 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
66
67
68
69
70
71
72
#!/usr/bin/env bash
# The 'close' command concludes a course by archiving project data and
# optionally deleting the team associated with the course. Depends on the
# 'user_config.sh' and 'system_config.sh' files.
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
close() {
# Archive data before closing the project
echo 'Running get_project_data_as_json()'
get_project_data_as_json
echo 'Running close_project()'
close_project
# Asking the user for confirmation for deleting the team
echo -n "${WRN} Are you sure you want to delete the team '${GH_TEAM_NAME}' "
echo "from organization '${GH_ORG_NAME}'? (no/yes) [no]:"
read -r user_confirm
# Asking the user for confirmation for removing members from an organization
if [[ "${user_confirm}" == 'yes' ]]; then
echo -n "${WRN} Do you want the team members, excluding the team "
echo -n "maintainers, to be removed from the organization '${GH_ORG_NAME}'?"
echo " (no/yes) [no]:"
read -r user_confirm
if [[ "${user_confirm}" == 'yes' ]]; then
echo 'Running remove_team_members_from_org()'
remove_team_members_from_org
fi
echo 'Running delete_team()'
delete_team
fi
}
close