Skip to content

Commit e8686aa

Browse files
committed
Upgrade to latest github workflow
1 parent 9354ad9 commit e8686aa

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.github/workflows/archive.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
build:
1717
name: "Archive Issues and Pull Requests"
1818
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
1921
steps:
2022
- name: "Checkout"
2123
uses: actions/checkout@v4

.github/workflows/ghpages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
build:
1919
name: "Update Editor's Copy"
2020
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
2123
steps:
2224
- name: "Checkout"
2325
uses: actions/checkout@v4

.github/workflows/setup.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: "Perform Initial Repository Setup"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
pre:
9+
name: "Setup Repository"
10+
runs-on: ubuntu-latest
11+
outputs:
12+
skip: ${{ steps.pre.outputs.skip }}
13+
steps:
14+
- name: "Checkout"
15+
uses: actions/checkout@v4
16+
17+
- name: "Precondition Check"
18+
id: pre
19+
run: |
20+
if ! ls draft-* rfc* 2>/dev/null | grep -qv draft-todo-yourname-protocol.md; then
21+
{
22+
echo "------------------------------------------------------------"
23+
echo "Skipping setup for the first commit."
24+
echo
25+
echo "Rename draft-todo-yourname-protocol.md to start using this repository:"
26+
echo
27+
echo "> https://github.com/${{github.repository}}/edit/main/draft-todo-yourname-protocol.md"
28+
echo
29+
echo "Change the name of the file and its title."
30+
echo "Commit the changes to the 'main' branch."
31+
echo
32+
echo "------------------------------------------------------------"
33+
} >>"$GITHUB_STEP_SUMMARY"
34+
echo "skip=true" >>"$GITHUB_OUTPUT"
35+
elif [ ! -f draft-todo-yourname-protocol.md -a -f Makefile ]; then
36+
{
37+
echo "------------------------------------------------------------"
38+
echo "Skipping setup for an already-configured repository."
39+
echo
40+
echo "Delete .github/workflows/setup.yml to avoid running this action:"
41+
echo
42+
echo "> https://github.com/${{github.repository}}/delete/main/.github/workflows/setup.yml"
43+
echo
44+
echo "------------------------------------------------------------"
45+
} >>"$GITHUB_STEP_SUMMARY"
46+
echo "skip=true" >>"$GITHUB_OUTPUT"
47+
else
48+
echo "skip=false" >>"$GITHUB_OUTPUT"
49+
fi
50+
51+
setup:
52+
name: "Setup Repository"
53+
runs-on: ubuntu-latest
54+
needs: pre
55+
if: ${{ needs.pre.outputs.skip != 'true' }}
56+
permissions:
57+
contents: write
58+
steps:
59+
- name: "Checkout"
60+
uses: actions/checkout@v4
61+
62+
- name: "Git Config"
63+
run: |
64+
git config user.email "idbot@example.com"
65+
git config user.name "I-D Bot"
66+
67+
- name: "Update Draft Name"
68+
run: |
69+
for i in draft-*; do
70+
if [ "$(head -1 "$i")" = "---" ]; then
71+
sed -i -e '2,/^---/{/^###/,/^###/d
72+
s|^docname: .*|docname: '"${i%.md}-latest"'|
73+
s|^ fullname: Your Name Here| fullname: "'"$(git show -q --format='format:%aN' @)"'"|
74+
s|^ email: your\.email@example\.com| email: "'"$(git show -q --format='format:%aE' @)"'"|
75+
}' "$i"
76+
fi
77+
sed -i -e "s/draft-todo-yourname-protocol-latest/${i%.md}-latest/g" "$i"
78+
git add "$i"
79+
done
80+
if [ -n "$(git status --porcelain draft-*)" ]; then
81+
git commit -m "Update draft labels" draft-*
82+
fi
83+
84+
- name: "Cleanup"
85+
run: |
86+
git rm -rf .github/workflows/setup.yml README.md
87+
git commit -m "Remove setup files"
88+
89+
- name: "Clone the i-d-template Repo"
90+
run: |
91+
git clone --depth=1 https://github.com/martinthomson/i-d-template lib
92+
93+
- name: "Run i-d-template Setup"
94+
uses: martinthomson/i-d-template@v1
95+
with:
96+
make: setup
97+
98+
- name: "Update Venue Information"
99+
uses: martinthomson/i-d-template@v1
100+
with:
101+
make: update-venue
102+
103+
- name: "Update GitHub Pages"
104+
uses: martinthomson/i-d-template@v1
105+
with:
106+
make: gh-pages
107+
108+
- name: "Push Changes"
109+
run: |
110+
git push

0 commit comments

Comments
 (0)