-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkickstart.sh
85 lines (69 loc) · 2.29 KB
/
kickstart.sh
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
83
84
85
#!/bin/bash
# Define the GitHub account or organization name
githubAccount="shaneholloman" # Change this to your personal account name if needed
# Initialize a new git repository
git init -b main
# Get the name of the current repository from the top-level directory
repoName=$(basename "$(git rev-parse --show-toplevel)")
# Create a new repository on GitHub using the gh CLI
gh repo create "$repoName" --public -y
# Add the remote repository
git remote add origin https://github.com/$githubAccount/"$repoName".git
# Add all files in the current directory to the git repository
git add .
# Commit the changes
git commit -m "Initial commit"
# Push the changes to GitHub
git push -u origin main
# Define an associative array where the key is the name of the secret and the value is the secret value
declare -A secrets
secrets=(
["DOCKERHUB_TOKEN"]="$DOCKERHUB_TOKEN"
["DOCKERHUB_USERNAME"]="$DOCKERHUB_USERNAME"
["GALAXY_API_KEY"]="$GALAXY_API_KEY"
# Add more secrets here as needed
)
# Check if environment variables exist
missingVars=()
for key in "${!secrets[@]}"
do
if [ -z "${secrets[$key]}" ]; then
missingVars+=("$key")
fi
done
if [ ${#missingVars[@]} -ne 0 ]; then
## Print 2 blank lines here to make the output easier to read
echo ""
echo ""
echo "The following environment variables are missing:"
for var in "${missingVars[@]}"
do
echo "$var"
done
echo "Please add them to your .bashrc file and run 'source ~/.bashrc'"
exit 1
fi
# Loop through each secret to set it for the current repository
for key in "${!secrets[@]}"
do
value=${secrets[$key]}
command="echo -n $value | gh secret set $key --repo=$githubAccount/$repoName"
eval "$command"
done
# Tag and push after setting the secrets
commitMessage="tagging first version"
tagVersion="2.0.0"
tagMessage="An Ansible role model template only"
git commit --allow-empty -m "$commitMessage"
git tag -a $tagVersion -m "$tagMessage"
# Ask the user if the current git tag and message are correct
## Print 2 blank lines here to make the output easier to read
echo ""
echo ""
echo "The current git tag is $tagVersion with the message '$tagMessage'. Is this correct? (yes/no)"
read -r answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
git push origin $tagVersion
else
echo "Please edit the git tag and message in this script."
fi