Skip to content

Included dot files while copying bundle-generator output #8

Included dot files while copying bundle-generator output

Included dot files while copying bundle-generator output #8

name: Template Cleanup
on:
push:
branches:
- main
jobs:
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'bundle-template'
permissions:
contents: write
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:
token: ${{ secrets.GITHUB_TOKEN }}
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)
PACKAGE_NAME=$(echo $NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
VENDOR_NAME=$(echo $ACTOR | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
VENDOR_NAMESPACE=$(echo $ACTOR | sed 's/\<./\U&/g' | sed 's/[^a-zA-Z0-9]//g')
# Converts repository name to UpperCamelCase (if separated by "-")
_temp=(${NAME//-/ })
BUNDLE_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 $PACKAGE_NAME $PACKAGE_NAME-dir --vendor-name=$VENDOR_NAME --vendor-namespace=$VENDOR_NAMESPACE --bundle-name=$BUNDLE_NAME --skeleton-name=extension
php .generator/bin/ibexa-bundle-generator $PACKAGE_NAME $PACKAGE_NAME-dir --vendor-name=$VENDOR_NAME --vendor-namespace=$VENDOR_NAMESPACE --bundle-name=$BUNDLE_NAME --skeleton-name=extension
# Remove ibexa/bundle-template workflows
rm -rf .github
# Move content
cp -R $PACKAGE_NAME-dir/{.,}* .
# Cleanup
rm -rf \
.github/readme \
.github/template-cleanup \
.github/workflows/template-cleanup.yml \
.generator composer-setup.php composer.phar \
$PACKAGE_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 }}