2020-06-19 05:36:30 +00:00
|
|
|
# GitHub Actions Workflow responsible for cleaning up the IntelliJ Platform Plugin Template repository from
|
2020-06-17 19:06:57 +00:00
|
|
|
# the template-specific files and configurations. This workflow is supposed to be triggered automatically
|
|
|
|
# when a new template-based repository has been created.
|
|
|
|
|
2020-06-19 07:51:04 +00:00
|
|
|
name: Template Cleanup
|
2020-06-17 19:06:57 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
2020-06-19 05:36:30 +00:00
|
|
|
# Run cleaning process only if workflow is triggered by the non-JetBrains/intellij-platform-plugin-template repository.
|
2020-06-17 19:06:57 +00:00
|
|
|
template-cleanup:
|
|
|
|
name: Template Cleanup
|
|
|
|
runs-on: ubuntu-latest
|
2020-06-19 05:36:30 +00:00
|
|
|
if: github.repository != 'JetBrains/intellij-platform-plugin-template'
|
2020-06-17 19:06:57 +00:00
|
|
|
steps:
|
|
|
|
|
|
|
|
# Check out current repository
|
|
|
|
- name: Fetch Sources
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
# Cleanup project
|
|
|
|
- name: Cleanup
|
|
|
|
run: |
|
|
|
|
export LC_CTYPE=C
|
|
|
|
export LANG=C
|
|
|
|
|
|
|
|
# Prepare variables
|
|
|
|
NAME="${GITHUB_REPOSITORY##*/}"
|
|
|
|
SAFE_NAME=$(echo $NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
|
|
|
|
ACTOR=$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')
|
|
|
|
GROUP="com.github.$ACTOR.$SAFE_NAME"
|
|
|
|
|
|
|
|
# Replace placeholders in the template-cleanup files
|
2020-06-18 09:18:51 +00:00
|
|
|
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/*
|
|
|
|
sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" .github/template-cleanup/*
|
|
|
|
sed -i "s/%GROUP%/$GROUP/g" .github/template-cleanup/*
|
2020-06-17 19:06:57 +00:00
|
|
|
|
|
|
|
# Replace template package name in project files with $GROUP
|
2020-06-18 09:18:51 +00:00
|
|
|
find src -type f -exec sed -i "s/org.jetbrains.plugins.template/$GROUP/g" {} +
|
2020-06-26 11:22:18 +00:00
|
|
|
find src -type f -exec sed -i "s/Template/$NAME/g" {} +
|
2020-06-18 20:09:41 +00:00
|
|
|
find src -type f -exec sed -i "s/JetBrains/$ACTOR/g" {} +
|
2020-06-17 19:06:57 +00:00
|
|
|
|
2020-06-26 09:26:31 +00:00
|
|
|
# Remove lines marked with #REMOVE-ON-CLEANUP#
|
|
|
|
find . -type f -exec sed -i '/#REMOVE-ON-CLEANUP#/d' {} +
|
2020-06-25 04:17:57 +00:00
|
|
|
|
2020-06-17 19:06:57 +00:00
|
|
|
# Move content
|
|
|
|
mkdir -p src/main/kotlin/${GROUP//.//}
|
|
|
|
cp -R .github/template-cleanup/* .
|
|
|
|
cp -R src/main/kotlin/org/jetbrains/plugins/template/* src/main/kotlin/${GROUP//.//}/
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
rm -rf .github/readme
|
|
|
|
rm -rf .github/template-cleanup
|
|
|
|
rm -rf src/main/kotlin/org
|
|
|
|
rm .github/workflows/template-cleanup.yml
|
|
|
|
|
|
|
|
# Commit modified files
|
|
|
|
- name: Commit files
|
|
|
|
run: |
|
|
|
|
git config --local user.email "action@github.com"
|
|
|
|
git config --local user.name "GitHub Action"
|
2020-06-26 11:11:11 +00:00
|
|
|
git add .
|
|
|
|
git commit -m "Template cleanup"
|
2020-06-17 19:06:57 +00:00
|
|
|
|
|
|
|
# Push changes
|
|
|
|
- name: Push changes
|
|
|
|
uses: ad-m/github-push-action@master
|
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|