-
Notifications
You must be signed in to change notification settings - Fork 186
55 lines (45 loc) · 1.65 KB
/
template-cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Workflow to cleanup projects created from this template
# Adapted from workflow of the same name in https://github.com/JetBrains/intellij-platform-plugin-template
# SPDX-License-Identifier: Apache-2.0
name: Template Cleanup
on:
push:
branches: [main]
jobs:
# Triggered on first push to repos created from the template
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'chisel-template'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cleanup
run: |
export LC_CTYPE=C
export LANG=C
# Prepare variables
NAME="${GITHUB_REPOSITORY##*/}"
ORG="$GITHUB_REPOSITORY_OWNER"
SAFE_ORG=$(echo $ORG | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
GROUP="com.github.$SAFE_ORG"
# Replace placeholders
sed -i "s/%NAME%/$NAME/g" build.sbt build.sc README.md src/test/scala/gcd
sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" README.md
sed -i "s/%ORGANIZATION%/$GROUP/g" build.sbt
# Remove lines marked with #REMOVE-ON-CLEANUP#
sed -i '/#REMOVE-ON-CLEANUP#/d' README.md
rm -rf \
.github/workflows/template-cleanup.yml \
LICENSE
- name: Commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Template cleanup"
- name: Push changes
uses: ad-m/[email protected]
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}