-
Notifications
You must be signed in to change notification settings - Fork 17
100 lines (88 loc) · 4.29 KB
/
template.yml
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
name: Template
on:
push:
branches:
- main
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
if: github.event.repository.name != 'spring-boot-scala-example'
steps:
- name: Fetch Sources
uses: actions/[email protected]
- name: Prepare
run: |
set -ex
export LC_CTYPE=C
export LANG=C
# Prepare variables
NAME="${GITHUB_REPOSITORY##*/}"
ACTOR=$(echo ${GITHUB_ACTOR} | tr '[:upper:]' '[:lower:]')
SAFE_NAME=$(echo ${NAME} | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
SAFE_ACTOR=$(echo $ACTOR | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
GROUP="com.github.${SAFE_ACTOR}.${SAFE_NAME}"
echo "Using GITHUB_REPOSITORY=${GITHUB_REPOSITORY}"
echo "Using GITHUB_ACTOR=${GITHUB_ACTOR}"
echo "Using NAME=${NAME}"
echo "Using GROUP=${GROUP}"
# Replace placeholders in the template-files files
sed -i "s/%NAME%/${NAME}/g" .github/template-files/*
sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" .github/template-files/*
sed -i "s/%GROUP%/${GROUP}/g" .github/template-files/*
# Update package references in sources
find src -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find src -type f -exec sed -i "s/spring.boot.scala.example/${GROUP}/g" {} +
# Update K8s deployment files
find deployment -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find deployment -type f -exec sed -i "s/spring.boot.scala.example/${GROUP}/g" {} +
find deployment -type f -exec sed -i "s/jecklgamis/${ACTOR}/g" {} +
# Update shell scripts
find . -name "*.sh" -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find . -name "*.sh" -type f -exec sed -i "s/spring.boot.scala.example/${GROUP}/g" {} +
find . -name "*.sh" -type f -exec sed -i "s/jecklgamis/${ACTOR}/g" {} +
# Update Makefile
find . -name Makefile -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find . -name Makefile -type f -exec sed -i "s/spring.boot.scala.example/${GROUP}/g" {} +
find . -name Makefile -type f -exec sed -i "s/jecklgamis/${ACTOR}/g" {} +
# Update pom.xml
find . -name pom.xml -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find . -name pom.xml -type f -exec sed -i "s/spring.boot.scala.example/${GROUP}/g" {} +
find . -name pom.xml -type f -exec sed -i "s/com.jecklgamis/${GROUP}/g" {} +
# Update build.sbt
find . -name build.sbt -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find . -name build.sbt -type f -exec sed -i "s/spring.boot.scala.example/${GROUP}/g" {} +
find . -name build.sbt -type f -exec sed -i "s/com.jecklgamis/${GROUP}/g" {} +
# Update Dockerfile
find . -name Dockerfile -type f -exec sed -i "s/spring-boot-scala-example/${NAME}/g" {} +
find . -name Dockerfile -type f -exec sed -i "s/Jerrico Gamis/FirstName LastName/g" {} +
find . -name Dockerfile -type f -exec sed -i "s/[email protected]/user@some-domain/g" {} +
# Copy content
mkdir -p src/main/scala/${GROUP//.//}
mkdir -p src/test/scala/${GROUP//.//}
cp -R .github/template-files/* .
cp -R src/main/scala/spring/boot/scala/example/* src/main/scala/${GROUP//.//}/
cp -R src/test/scala/spring/boot/scala/example/* src/test/scala/${GROUP//.//}/
# Clean up
rm -rf \
.circleci \
.github/readme \
.github/template-files \
.github/workflows/template.yml \
.idea/icon.png \
src/main/scala/spring \
src/test/scala/spring \
LICENSE
- name: Commit files
run: |
export LC_CTYPE=C
export LANG=C
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -a -m "Prepare repo"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}