-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws-create-codeartifact.sh
More file actions
executable file
·82 lines (65 loc) · 2.22 KB
/
aws-create-codeartifact.sh
File metadata and controls
executable file
·82 lines (65 loc) · 2.22 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
73
74
75
76
77
78
79
80
81
82
#!/bin/bash -e
# Strict Mode
set -euo pipefail
IFS=$'\n\t'
usage() {
echo "
Create a new CodeArtifact repository, for storing of npm packages.
Arguments:
-h Show help info.
-d An optional domain for the CodeArtifact repository, if unspecified the default domain is used.
-g The git repo name to use in the CodeArtifact repository name (e.g. 'react-native-foobar-bundlekit').
-r The AWS region in which to create the CodeArtifact repository (e.g. 'eu-west-2').
Arguments:
Example usages:
./aws-create-codeartifact.sh -r \"eu-west-2\" -g \"react-native-foobar-bundlekit\"
./aws-create-codeartifact.sh -r \"eu-west-2\" -g \"react-native-foobar-bundlekit\" -d \"mydomain\"
"
exit 0
}
# Exit codes:
# (1) - Invalid arguments specified.
#
main() {
FILENAME="aws-create-codeartifact"
PY_FILE="${FILENAME}.py"
DOMAIN=""
GIT_REPO=""
REGION=""
while getopts ":hd:g:r:" arg; do
case $arg in
h) usage ;;
d) DOMAIN="${OPTARG}" ;;
g) GIT_REPO="${OPTARG}" ;;
r) REGION="${OPTARG}" ;;
*) usage ;;
esac
done
shift $((OPTIND - 1))
if [[ -z "${REGION}" ]]; then
printf "%s\n%s\n%s\n\n" "ERROR: Option '-r' required." "${EXAMPLE_DESC_REGION}" "${HELP_DESC}" 1>&2
exit 1
fi
if [[ -z "${GIT_REPO}" ]]; then
printf "%s\n%s\n%s\n\n" "ERROR: Option '-g' required." "${EXAMPLE_DESC_GIT_REPO}" "${HELP_DESC}" 1>&2
exit 1
elif [[ "${GIT_REPO}" == *"base"* ]]; then
while true; do
echo ""
read -r -p "Warning: You've specified a 'base' git repo name (for creating a CodeArtifact repository). Are you sure you'd like to continue: '${GIT_TAG}' ? [y/n] " yn
case $yn in
[Yy]*) echo "... Continuing" && break ;;
[Nn]*) echo "... Exiting script" && exit 1 ;;
*) printf "\n%s\n" "Please answer [y/n]." ;;
esac
done
fi
if [[ -z "${DOMAIN}" ]]; then
printf "%s\n\n" "## Creating a new CodeArtifact repository"
python3 ${PY_FILE} --region "${REGION}" --repo "${GIT_REPO}"
else
printf "%s\n\n" "## Creating a new CodeArtifact repository, with custom CodeArtifact domain: ${DOMAIN}"
python3 ${PY_FILE} --region "${REGION}" --repo "${GIT_REPO}" --domain "${DOMAIN}"
fi
}
main "$@"