-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsync-gh-actions.sh
105 lines (104 loc) · 3.68 KB
/
sync-gh-actions.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# Assign NetCoreTemplates directory
export NETCORE_TEMPLATES_DIR=$(realpath "../../NetCoreTemplates")
export SHOULD_BRANCH=0
export START_DIR=$(pwd)
# Declare three lists of template names
# Templates with DB migrations, array of strings
export TEMPLATES_WITH_MIGRATIONS=(
"blazor"
"blazor-vue"
# "blazor-wasm"
# "vue-mjs"
# "mvc-tailwind"
)
# Templates without DB migrations, array of strings
export TEMPLATES_WITHOUT_MIGRATIONS=(
# "angular-spa"
# "aurelia-spa"
# "react-spa"
# "svelte-spa"
# "vue-nuxt"
# "vue-spa"
# "vuetify-nuxt"
# "vuetify-spa"
# "web-tailwind"
# "mvcauth"
# "mvc"
# "razor-pages"
# "razor-tailwind"
# "parcel"
# "razor"
# "script"
# "web"
)
# Templates that use CDN/API split, array of strings
export TEMPLATES_FOR_CDN=(
# "nextjs"
# "vue-vite"
# "vue-ssg"
)
# Copy the folder `actions/dotnet-docker-db` for the templates with DB migrations using the list of template names
# and the variable NETCORE_TEMPLATES_DIR. Combine to create a path to the template folder, and then copy the folder.
# Ensure to overwrite the folder if it already exists in the target templates.
for i in "${TEMPLATES_WITH_MIGRATIONS[@]}"
do
# If SHOULD_BRANCH is set to 1, create a new git branch for the template
if [ "$SHOULD_BRANCH" -eq 1 ]; then
cd "$NETCORE_TEMPLATES_DIR/$i"
git checkout -b "sync-gh-actions"
cd "$START_DIR"
fi
echo "Copying to $NETCORE_TEMPLATES_DIR/$i/"
cp -a actions/dotnet-docker-db/. "$NETCORE_TEMPLATES_DIR/$i/"
# If SHOULD_BRANCH is set to 1, commit the changes and push to the remote
if [ "$SHOULD_BRANCH" -eq 1 ]; then
cd "$NETCORE_TEMPLATES_DIR/$i"
git add .
git commit -m "Sync GitHub Actions"
git push origin "sync-gh-actions"
cd "$START_DIR"
fi
done
# Copy the folder `actions/dotnet-docker` for the templates without DB migrations using the list of template names
# and the variable NETCORE_TEMPLATES_DIR. Combine to create a path to the template folder, and then copy the folder.
# Ensure to overwrite the folder if it already exists in the target templates.
for i in "${TEMPLATES_WITHOUT_MIGRATIONS[@]}"
do
# If SHOULD_BRANCH is set to 1, create a new git branch for the template
if [ "$SHOULD_BRANCH" -eq 1 ]; then
cd "$NETCORE_TEMPLATES_DIR/$i"
git checkout -b "sync-gh-actions"
cd "$START_DIR"
fi
cp -a actions/dotnet-docker/. "$NETCORE_TEMPLATES_DIR/$i/"
# If SHOULD_BRANCH is set to 1, commit the changes and push to the remote
if [ "$SHOULD_BRANCH" -eq 1 ]; then
cd "$NETCORE_TEMPLATES_DIR/$i"
git add .
git commit -m "Sync GitHub Actions"
git push origin "sync-gh-actions"
cd "$START_DIR"
fi
done
# Copy the folder `actions/dotnet-docker-cdn` for the templates with CDN/API split using the list of template names
# and the variable NETCORE_TEMPLATES_DIR. Combine to create a path to the template folder, and then copy the folder.
# Ensure to overwrite the folder if it already exists in the target templates.
for i in "${TEMPLATES_FOR_CDN[@]}"
do
# If SHOULD_BRANCH is set to 1, create a new git branch for the template
if [ "$SHOULD_BRANCH" -eq 1 ]; then
cd "$NETCORE_TEMPLATES_DIR/$i"
git checkout -b "sync-gh-actions"
cd "$START_DIR"
fi
cp -a actions/dotnet-docker-cdn/. "$NETCORE_TEMPLATES_DIR/$i/"
# If SHOULD_BRANCH is set to 1, commit the changes and push to the remote
if [ "$SHOULD_BRANCH" -eq 1 ]; then
cd "$NETCORE_TEMPLATES_DIR/$i"
git add .
git commit -m "Sync GitHub Actions"
git push origin "sync-gh-actions"
cd "$START_DIR"
fi
done