-
Notifications
You must be signed in to change notification settings - Fork 13
52 lines (45 loc) · 1.6 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
# This workflow is supposed to be triggered automatically when a new template-based repository has been created.
# @see https://github.com/JetBrains/intellij-platform-plugin-template/blob/main/.github/workflows/template-cleanup.yml
# @see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
name: Template Cleanup
on:
push:
branches:
- main
jobs:
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'srs-k8s-template'
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2.4.0
# Cleanup project
# github.repository Codertocat/Hello-World
# NAME Hello-World
- name: Cleanup
run: |
# Prepare variables.
NAME="${GITHUB_REPOSITORY##*/}"
TMPL_NAME="%NAME%"
# Replace repository name and links.
cp template/README.md .
sed -i "s|ossrs/$TMPL_NAME|${{ github.repository }}|g" README.md
sed -i "s/$TMPL_NAME/$NAME/g" README.md
# Cleanup
rm -f .github/workflows/template-cleanup.yml
rm -rf template
# 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 }}