-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (40 loc) · 1.4 KB
/
initialize.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
name: initialize
on:
push:
branches:
- master
jobs:
initialize:
name: Initialize
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Replace repository and package name
run: |
name=$(grep -o '"name": "[^"]*' package.json | cut -d'"' -f4)
repository=$(grep -o '"repository": "[^"]*' package.json | cut -d'"' -f4)
sed -i "s#${repository}#${{github.repository}}#g" package.json readme.md
sed -i "s#${name}#${{github.event.repository.name}}#g" package.json readme.md
- name: Remove lockfiles from .gitignore
run: |
sed -i '/yarn.lock/d' .gitignore
sed -i '/package-lock.json/d' .gitignore
- name: Remove template related content
run: |
sed -i 's#"description":.*#"description": "",#' package.json
sed -i '1,6!d' readme.md
- name: Clean
run: rm .github/workflows/initialize.yml
- name: Push changes
run: |
if (( $(git rev-list --count HEAD) < 2 ))
then
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add --all
git commit -m "Template initialization"
git push "https://${{github.actor}}:${{github.token}}@github.com/${{github.repository}}.git" HEAD:master
else
echo Skip pushing changes in template repository
fi