Skip to content

Merge pull request #5 from jecklgamis/next #7

Merge pull request #5 from jecklgamis/next

Merge pull request #5 from jecklgamis/next #7

Workflow file for this run

name: Template
on:
push:
branches:
- main
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
if: github.event.repository.name != 'flask-app-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:]')
echo "Using GITHUB_REPOSITORY=${GITHUB_REPOSITORY}"
echo "Using GITHUB_ACTOR=${GITHUB_ACTOR}"
echo "Using NAME=${NAME}"
# Update package references in sources
find app -type f -exec sed -i "s/flask-app-example/${NAME}/g" {} +
find tests -type f -exec sed -i "s/flask-app-example/${NAME}/g" {} +
# 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/*
# Update shell scripts
find . -name "*.sh" -type f -exec sed -i "s/flask-app-example/${NAME}/g" {} +
find . -name "*.sh" -type f -exec sed -i "s/jecklgamis/${ACTOR}/g" {} +
# Update Makefile
find . -name Makefile -type f -exec sed -i "s/flask-app-example/${NAME}/g" {} +
find . -name Makefile -type f -exec sed -i "s/jecklgamis/${ACTOR}/g" {} +
# Update Dockerfile
find . -name Dockerfile -type f -exec sed -i "s/flask-app-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
cp -R .github/template-files/* .
# Clean up
rm -rf \
.github/template-files \
.github/workflows/template.yml \
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 }}