Skip to content

Update cookiecutter.json #2

Update cookiecutter.json

Update cookiecutter.json #2

name: Setup repository
on:
push:
paths:
- cookiecutter.json
jobs:
setup:
name: Reinitialize repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip install cookiecutter
- name: Scaffolding repository
# cookiecutter is command-line utility to create projects from templates
# https://github.com/cookiecutter/cookiecutter
#
# --no-input Do not prompt for parameters and only use
# cookiecutter.json file content
#
# --output-dir Where to output the generated project dir into
run: cookiecutter . --no-input --output-dir ./cookiecutter-temp
- name: Prepare root directory
shell: bash
# Remove all files and folder exepct .git/ and cookiecutter-temp/
run: |
find ./ -maxdepth 1 \
! -name '.git' \
! -name 'cookiecutter-temp' \
! -name '.' \
! -exec rm -rf {} +
- name: Move files to root
shell: bash
# The cookiecutter-temp/ folder contains a single folder which is the
# generated project by cookiecutter. We want to move all the project
# files into the root directory so we can reinitialize git in the next step
run: |
rsync -r ./cookiecutter-temp/*/ . && \
rm -rf ./cookiecutter-temp/
- name: Reinitialize git repository
shell: bash
# Reinitialize git after scaffolding this repository.
# We use `git checkout --orphan` to create a branch in a git init-like state.
# By force pushing this as `main` we end up with a new clean git history.
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com" && \
git config --global user.name "github-actions[bot]" && \
git checkout --orphan temp-branch && \
git add . && \
git commit -m 'Initial commit' && \
git push origin temp-branch:main -f