Skip to content

Merge pull request #5 from jecklgamis/next #4

Merge pull request #5 from jecklgamis/next

Merge pull request #5 from jecklgamis/next #4

Workflow file for this run

name: Template
on:
push:
branches:
- main
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
if: github.event.repository.name != 'spring-boot-java-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-java-example/${NAME}/g" {} +
find src -type f -exec sed -i "s/spring.boot.java.example/${GROUP}/g" {} +
# Update K8s deployment files
find deployment -type f -exec sed -i "s/spring-boot-java-example/${NAME}/g" {} +
find deployment -type f -exec sed -i "s/spring.boot.java.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-java-example/${NAME}/g" {} +
find . -name "*.sh" -type f -exec sed -i "s/spring.boot.java.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-java-example/${NAME}/g" {} +
find . -name Makefile -type f -exec sed -i "s/spring.boot.java.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-java-example/${NAME}/g" {} +
find . -name pom.xml -type f -exec sed -i "s/spring.boot.java.example/${GROUP}/g" {} +
find . -name pom.xml -type f -exec sed -i "s/com.jecklgamis/${GROUP}/g" {} +
# Update Dockerfile
find . -name Dockerfile -type f -exec sed -i "s/spring-boot-java-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/java/${GROUP//.//}
mkdir -p src/test/java/${GROUP//.//}
cp -R .github/template-files/* .
cp -R src/main/java/spring/boot/java/example/* src/main/java/${GROUP//.//}/
# Clean up
rm -rf \
.circleci \
.github/readme \
.github/template-files \
.github/workflows/template.yml \
.idea/icon.png \
src/main/java/spring \
src/test/java/spring \
LICENSE
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Prepare repo"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}