aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/template-cleanup.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/template-cleanup.yml')
-rw-r--r--.github/workflows/template-cleanup.yml69
1 files changed, 0 insertions, 69 deletions
diff --git a/.github/workflows/template-cleanup.yml b/.github/workflows/template-cleanup.yml
deleted file mode 100644
index e88e9d1..0000000
--- a/.github/workflows/template-cleanup.yml
+++ /dev/null
@@ -1,69 +0,0 @@
-# GitHub Actions Workflow responsible for cleaning up the Advent of Code Kotlin 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.
-
-name: Template Cleanup
-on:
- push:
- branches:
- - main
-
-jobs:
-
- # Run cleaning process only if workflow is triggered by the .../advent-of-code-kotlin-template repository.
- template-cleanup:
- name: Template Cleanup
- runs-on: ubuntu-latest
- if: github.event.repository.name != 'advent-of-code-kotlin-template'
- steps:
-
- # Check out current repository
- - name: Fetch Sources
- uses: actions/checkout@v2.4.0
-
- # 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:]')
- GROUP="com.github.$SAFE_ACTOR.$SAFE_NAME"
-
- # Replace placeholders in the template-cleanup files
- sed -i "s/%ACTOR%/$ACTOR/g" .github/template-cleanup/*
- 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/*
-
- # Move content
- cp -R .github/template-cleanup/* .
-
- # Cleanup
- rm -rf \
- .github/readme \
- .github/template-cleanup \
- .github/workflows/template-cleanup.yml \
- LICENSE
-
- # Remove leftover empty directories
- find . -type d -empty -delete
-
- # Commit modified files
- - name: Commit files
- run: |
- git config --local user.email "action@github.com"
- 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 }}