generated from martinthomson/internet-draft-template
-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (88 loc) · 3.42 KB
/
setup.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: "Perform Initial Repository Setup"
on:
push:
branches: [main]
jobs:
setup:
name: "Setup Repository"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Precondition Check"
id: pre
run: |
if ! ls draft-* rfc* 2>/dev/null | grep -qv draft-todo-yourname-protocol.md; then
echo "============================================================="
echo "Skipping setup for the first commit."
echo
echo "Rename draft-todo-yourname-protocol.md to start using this repository:"
echo
echo " https://github.com/${{github.repository}}/edit/main/draft-todo-yourname-protocol.md"
echo
echo "Change the name of the file and its title."
echo "Commit the changes to the 'main' branch."
echo
echo "============================================================="
echo "skip=true" >>"$GITHUB_OUTPUT"
elif [ ! -f draft-todo-yourname-protocol.md -a -f Makefile ]; then
echo "============================================================="
echo "Skipping setup for an already-configured repository."
echo
echo "Delete .github/workflows/setup.yml to avoid running this action:"
echo
echo " https://github.com/${{github.repository}}/delete/main/.github/workflows/setup.yml"
echo
echo "============================================================="
echo "skip=true" >>"$GITHUB_OUTPUT"
fi
- name: "Git Config"
if: ${{ steps.pre.outputs.skip != 'true' }}
run: |
git config user.email "[email protected]"
git config user.name "I-D Bot"
- name: "Update Draft Name"
if: ${{ steps.pre.outputs.skip != 'true' }}
run: |
for i in draft-*; do
if [ "$(head -1 "$i")" = "---" ]; then
sed -i -e '2,/^---/{/^###/,/^###/d
s|^docname: .*|docname: '"${i%.md}-latest"'|
s|^ fullname: Your Name Here| fullname: "'"$(git show -q --format='format:%aN' @)"'"|
s|^ email: your\.email@example\.com| email: "'"$(git show -q --format='format:%aE' @)"'"|
}' "$i"
fi
sed -i -e "s/draft-todo-yourname-protocol-latest/${i%.md}-latest/g" "$i"
git add "$i"
done
if [ -n "$(git status --porcelain draft-*)" ]; then
git commit -m "Update draft labels" draft-*
fi
- name: "Cleanup"
if: ${{ steps.pre.outputs.skip != 'true' }}
run: |
git rm -rf .github/workflows/setup.yml README.md
git commit -m "Remove setup files"
- name: "Clone the i-d-template Repo"
if: ${{ steps.pre.outputs.skip != 'true' }}
run: |
git clone --depth=1 https://github.com/martinthomson/i-d-template lib
- name: "Run i-d-template Setup"
if: ${{ steps.pre.outputs.skip != 'true' }}
uses: martinthomson/i-d-template@v1
with:
make: setup
- name: "Update Venue Information"
if: ${{ steps.pre.outputs.skip != 'true' }}
uses: martinthomson/i-d-template@v1
with:
make: update-venue
- name: "Update GitHub Pages"
if: ${{ steps.pre.outputs.skip != 'true' }}
uses: martinthomson/i-d-template@v1
with:
make: gh-pages
- name: "Push Changes"
if: ${{ steps.pre.outputs.skip != 'true' }}
run: |
git push