Skip to content

.github/workflows/cleanup-on-create.yaml #2

.github/workflows/cleanup-on-create.yaml

.github/workflows/cleanup-on-create.yaml #2

# This workflow will run upon repository creation and clean up
# all files that are not strictly required to build an AEM Live project
# but that we use to develop the project template. This includes this
# particular workflow file.
on:
create:
branches:
- main
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
# only run if commit message is "Initial commit" on main branch
if: ${{ github.event_name == 'workflow_dispatch' || ( github.ref == 'refs/heads/main' && !(contains(github.event, 'head_commit') || github.event.head_commit.message == 'Initial commit' )) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Remove Helper Files
run: |
rm -rf \
.github/workflows/cleanup-on-create.yaml \
CHANGELOG.md
- name: Remove Form Developement Files
run: |
rm -rf \
.circleci .npmrc test rollup
- name: Update .eslintignore
run: |
sed -i '/^rollup/d' .eslintignore
sed -i '/^helix-importer-ui/d' .eslintignore
- name: Update Package.json
run: |
rm -rf package.json package-lock.json
mv package-prod.json package.json
- name: Initialize README
# replace {repo} and {owner} with the actual values
run: |
sed -i.bak "s/{repo}/$(basename ${{ github.repository }})/g" README.md
sed -i.bak "s/{owner}/$(dirname ${{ github.repository }})/g" README.md
- name: Initialize Pull Request Template
run: |
sed -i.bak "s/{repo}/$(basename ${{ github.repository }})/g" .github/pull_request_template.md
sed -i.bak "s/{owner}/$(dirname ${{ github.repository }})/g" .github/pull_request_template.md
# commit back to the repository
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "AEM Bot"
git add .
git commit -m "chore: cleanup repository template"
git push