-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-workflow
More file actions
executable file
·38 lines (33 loc) · 1021 Bytes
/
setup-workflow
File metadata and controls
executable file
·38 lines (33 loc) · 1021 Bytes
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
#!/bin/bash
set -e
script_dir=$(cd "$(dirname "$0")" ; pwd -P)
usage() { echo "Usage: $0 [-p <project name: string>] [-m <module name: string>]" 1>&2; exit 1; }
while getopts ":p:m:" o; do
case "${o}" in
p)
project=${OPTARG}
;;
m)
module=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${project}" ] || [ -z "${module}" ]; then
usage
fi
pushd "${script_dir}" > /dev/null
echo "Creating workflow"
cp .github/workflows/example.yml.tpl ".github/workflows/${module}.yml"
if [ $OSTYPE == "linux-gnu" ]; then
sed -i -e s/example1\-example2/${module}/g ./.github/workflows/${module}.yml
sed -i -e s/example\-project/${project}/g ./.github/workflows/${module}.yml
else
sed -i '' -e s/example1\-example2/${module}/g ./.github/workflows/${module}.yml
sed -i '' -e s/example\-project/${project}/g ./.github/workflows/${module}.yml
fi
echo "Workflow created"
popd > /dev/null