Skip to content

Adapted clean up workflow #2

Adapted clean up workflow

Adapted clean up workflow #2

name: Template Cleanup
on:
push:
branches:
- main
jobs:
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'bundle-template'
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
extensions: pdo_sqlite, gd
tools: cs2pr
- name: Get bundle generator
uses: actions/checkout@v2
with:
repository: ibexa/bundle-generator
path: .generator
- name: "Install composer and dependencies"
run: |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php composer.phar install -d .generator
# Cleanup project
- name: Cleanup
run: |
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:]')
# Converts repository name to UpperCamelCase (if separated by "-")
_temp=(${NAME//-/ })
CC_NAME=$(printf %s "${_temp[@]^}")
# Remove lines marked with #REMOVE-ON-CLEANUP#
find . -type f -exec sed -i '/#REMOVE-ON-CLEANUP#/d' {} +
# Run generator
echo Running generator with: php .generator/bin/ibexa-bundle-generator $SAFE_NAME $SAFE_NAME-dir --vendor-name=ibexa --vendor-namespace=Ibexa --bundle-name=$CC_NAME --skeleton-name=extension
php .generator/bin/ibexa-bundle-generator $SAFE_NAME $SAFE_NAME-dir --vendor-name=ibexa --vendor-namespace=Ibexa --bundle-name=$CC_NAME --skeleton-name=extension
# Move content
cp -R $SAFE_NAME-dir/* .
# Cleanup
rm -rf \
.github/readme \
.github/template-cleanup \
.github/workflows/template-cleanup.yml \
.generator composer-setup.php composer.phar \
$SAFE_NAME-dir
# Commit modified files
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Template cleanup"
# Push changes
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}