2023-08-07 13:36:00 +00:00
# GitHub Actions Workflow responsible for cleaning up the IntelliJ Platform Plugin Template repository from 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-17 19:06:57 +00:00
2020-06-19 07:51:04 +00:00
name : Template Cleanup
2020-06-17 19:06:57 +00:00
on :
push :
2022-09-19 11:42:48 +00:00
branches : [ main]
2020-06-17 19:06:57 +00:00
jobs :
2023-01-13 20:34:46 +00:00
# Run a cleaning process only if the workflow is triggered by the non-"intellij-platform-plugin-template" repository.
2020-06-17 19:06:57 +00:00
template-cleanup :
name : Template Cleanup
runs-on : ubuntu-latest
2022-09-19 11:42:48 +00:00
if : github.event.repository.name != 'intellij-platform-plugin-template'
2022-05-10 07:36:44 +00:00
permissions :
contents : write
2020-06-17 19:06:57 +00:00
steps :
# Check out current repository
- name : Fetch Sources
2023-09-05 06:17:09 +00:00
uses : actions/checkout@v4
2020-06-17 19:06:57 +00:00
# Cleanup project
- name : Cleanup
run : |
export LC_CTYPE=C
export LANG=C
# Prepare variables
NAME="${GITHUB_REPOSITORY##*/}"
ACTOR=$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')
2020-12-28 11:21:50 +00:00
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:]')
GROUP="com.github.$SAFE_ACTOR.$SAFE_NAME"
2020-06-17 19:06:57 +00:00
# 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" {} +
2024-03-08 12:19:02 +00:00
find src -type f -exec sed -i "s/IntelliJ Platform Plugin 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
# Move content
mkdir -p src/main/kotlin/${GROUP//.//}
2021-09-02 13:44:46 +00:00
mkdir -p src/test/kotlin/${GROUP//.//}
2023-07-10 07:30:28 +00:00
cp -R .github/template-cleanup/. .
2020-06-17 19:06:57 +00:00
cp -R src/main/kotlin/org/jetbrains/plugins/template/* src/main/kotlin/${GROUP//.//}/
2021-09-02 13:44:46 +00:00
cp -R src/test/kotlin/org/jetbrains/plugins/template/* src/test/kotlin/${GROUP//.//}/
2020-06-17 19:06:57 +00:00
# Cleanup
2020-11-16 10:26:43 +00:00
rm -rf \
2021-09-23 09:21:30 +00:00
.github/ISSUE_TEMPLATE \
2020-11-16 10:26:43 +00:00
.github/readme \
.github/template-cleanup \
.github/workflows/template-cleanup.yml \
2022-09-19 09:18:36 +00:00
.github/workflows/template-verify.yml \
2020-11-16 10:26:43 +00:00
.idea/icon.png \
src/main/kotlin/org \
2021-09-02 13:44:46 +00:00
src/test/kotlin/org \
2023-02-23 14:51:44 +00:00
src/main/resources/META-INF/pluginIcon.svg \
2020-11-16 10:26:43 +00:00
CODE_OF_CONDUCT.md \
LICENSE
2020-06-17 19:06:57 +00:00
# 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 :
2020-09-10 17:22:39 +00:00
branch : main
2020-06-17 19:06:57 +00:00
github_token : ${{ secrets.GITHUB_TOKEN }}