-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (64 loc) · 2.54 KB
/
cleanTemplate.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Clean Template
on:
# run when branch created (repo generated from template)
create:
# only keep latest run of this workflow
concurrency:
group: first-time-setup
cancel-in-progress: false
# ADDED THIS CHANGE
permissions:
actions: write
checks: write
contents: write
jobs:
first-time-setup:
# ensure run only once, when repo generated
if: github.run_number == 1
runs-on: ubuntu-latest
steps:
# get main branch repo contents
- name: Checkout code
uses: actions/checkout@v4
# remove files not needed for user instance of template
- name: Remove unneeded files
run: |
# Prepare variables
NAME="${GITHUB_REPOSITORY##*/}"
USER=$GITHUB_REPOSITORY_OWNER
# update placeholders
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/README.md
sed -i "s/%USER%/$USER/g" .github/template-cleanup/README.md
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/config/hugo.yaml
sed -i "s/%USER%/$USER/g" .github/template-cleanup/config/hugo.yaml
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/config/params.yaml
sed -i "s/%USER%/$USER/g" .github/template-cleanup/config/params.yaml
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/go.mod
sed -i "s/%USER%/$USER/g" .github/template-cleanup/go.mod
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/content/about.md
sed -i "s/%USER%/$USER/g" .github/template-cleanup/content/about.md
# replace files
cp -R .github/template-cleanup/README.md .
cp -R .github/template-cleanup/config/* config/_default/
cp -R .github/template-cleanup/go.mod .
cp -R .github/template-cleanup/content/* content/
# move files
mv -f .github/workflows/buildDeploy.yaml .github/deploymentWorkflow/buildDeploy.yaml
# download new author and thumbnail images
wget -O assets/author.png https://github.com/$USER.png
wget -O assets/thumbnail.png https://github.com/$USER.png
# remove files
rm -rf \
.github/ISSUE_TEMPLATE/ \
.github/workflows/ \
.github/template-cleanup/ \
.github/renovate.json \
go.sum \
LICENSE \
assets/author.jpeg \
assets/thumbnail.jpeg
# save changed files
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Setup and populate your repo"