-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreplace.sh
executable file
·44 lines (36 loc) · 1.29 KB
/
replace.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
#!/bin/bash
if [ -z "$1" ]; then
echo "Enter role name: "
read NEW_ROLE_NAME
else
NEW_ROLE_NAME=$1
fi
if [ -z "$2" ]; then
if [ -z "$GITHUB_USER" ]; then
echo "Enter github user: "
read GITHUB_USER
fi
else
GITHUB_USER="$2"
fi
if [ "$ROLE_IN_COLLECTION" != "true" ]; then # So I can skip this when using the template for a role in a collection
if [ -z "$GALAXY_API_KEY" ]; then
echo "Enter galaxy api key: "
read GALAXY_API_KEY
fi
fi
find defaults handlers meta molecule tasks tests vars LICENSE README.md \
-type f -exec sed -i -e "s/diademiemi/${GITHUB_USER}/g" -e "s/template/${NEW_ROLE_NAME}/g" {} + # Do not run this more than once
if [ "$ROLE_IN_COLLECTION" != "true" ]; then
# Assumes repo is named ansible_role_${NEW_ROLE_NAME}
gh secret set GALAXY_API_KEY -R ${GITHUB_USER}/ansible_role_${NEW_ROLE_NAME} -a actions -b ${GALAXY_API_KEY}
mv ansible_role_template.code-workspace ansible_role_${NEW_ROLE_NAME}.code-workspace
else
if [ "$ROLE_IN_COLLECTION" == "true" ]; then
rm -r ./.github ./.gitlab-ci.yml ansible_role_template.code-workspace .gitignore LICENSE
sed -i "s/\[\!\[Molecule Test\].*//g" README.md
fi
fi
# Remove this section from README.md
sed -i "/Role Structure/Q" README.md
rm ./replace.sh