-
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (108 loc) · 4.53 KB
/
build.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: "Build GitHub Pages"
run-name: "Build GitHub Pages"
on:
workflow_call:
push:
branches-ignore: [main]
pull_request:
branches: [main]
types:
- opened
- edited
- reopened
- synchronize
- ready_for_review
permissions:
contents: read
env:
GH_TOKEN: ${{ github.token }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install tools"
run: sudo apt install tidy pandoc
- name: "Install templates"
run: |
mkdir -p ~/.pandoc/templates
curl -sSL 'https://github.com/tajmone/pandoc-goodies/raw/refs/heads/master/templates/html5/github/GitHub.html5' -o ~/.pandoc/templates/GitHub.html5
- name: "Generate a security.txt file"
run: |
tee security.txt << EOF
Contact: $(gh api /repos/${{ github.repository }} --jq '.homepage')/contact
Policy: $(gh api /repos/${{ github.repository }} --jq '.homepage')/security/policy
Acknowledgments: $(gh api /repos/${{ github.repository }} --jq '.homepage')/humans.txt
Canonical: $(gh api /repos/${{ github.repository }} --jq '.homepage')/security.txt
Expires: $(date -u +"%Y-12-31T23:59:59.999Z")
EOF
- name: "Generate a humans.txt file"
run: gh api "${ENDPOINT}" --template "${TEMPLATE}" | sh | tee humans.txt
env:
ENDPOINT: '/orgs/${{ github.repository_owner }}/repos'
TEMPLATE: |
echo "# Contributors by Repository"
echo
echo "A huge thanks to all and colaborators who have contributed on GitHub!"
echo
{{range .}}
echo "## {{.full_name}}"
echo
gh api /repos/{{.full_name}}/contributors --jq '.[].login' | sort -u | xargs -ILOGIN gh api /users/LOGIN --jq '"- @" + .login + " (" + (.name // .login) + ")"'
echo
{{end}}
- name: "Generate a changelog.md file"
run: gh api "${ENDPOINT}" --template "${TEMPLATE}" | tee changelog.md
env:
ENDPOINT: '/repos/${{ github.repository }}/releases'
TEMPLATE: |
---
lang: en
title-meta: Changelog
...
# Change Log
{{range .}}
### [{{.name}}](https://${{ github.server_url }}/${{ github.repository }}/releases/tag/{{.tag_name}})
{{.body}}
{{end}}
- name: "Retrieve Code of Conduct"
run: curl -H "${MEDIA_TYPE_HEADER}" -H "${AUTH_TOKEN_HEADER}" -o code-of-conduct.md "${CONTENTS_ENDPOINT}/CODE_OF_CONDUCT.md"
env:
CONTENTS_ENDPOINT: '${{ github.api_url }}/repos/${{ github.repository_owner }}/.github/contents'
MEDIA_TYPE_HEADER: "Accept: application/vnd.github.raw"
AUTH_TOKEN_HEADER: "Authorization: Bearer ${{ github.token }}"
- name: "Retrieve Contribution Guidlines"
run: curl -H "${MEDIA_TYPE_HEADER}" -H "${AUTH_TOKEN_HEADER}" -o contributing.md "${CONTENTS_ENDPOINT}/CONTRIBUTING.md"
env:
CONTENTS_ENDPOINT: '${{ github.api_url }}/repos/${{ github.repository_owner }}/.github/contents'
MEDIA_TYPE_HEADER: "Accept: application/vnd.github.raw"
AUTH_TOKEN_HEADER: "Authorization: Bearer ${{ github.token }}"
- name: "Create generated HTML files"
run: |
make -f - << \EOF
all: index.html $(patsubst %.md,%.html,$(wildcard *.md */*.md */*/*.md))
rm -f header.html
index.md:
cp README.md index.md
%.html: %.md
pandoc --template=GitHub.html5 --include-in-header=header.html --from markdown+yaml_metadata_block+backtick_code_blocks+fenced_code_attributes+inline_notes+emoji --to html --standalone $< --output $@
EOF
- name: "Create redirect HTML files"
run: |
make -f - << \EOF
all: $(patsubst %.redirect,%.html,$(wildcard *.redirect */*.redirect */*/*.redirect))
rm -f redirect.html $(wildcard *.redirect */*.redirect */*/*.redirect)
%.html: %.redirect
@echo "Generating $@..."
$(file > $@, $(subst {{ .REDIRECT }},$(file < $<),$(file < redirect.html)))
EOF
- name: "Tidy the HTML"
run: find . -name '*.html' | xargs tidy -indent --wrap 0 --output-html yes --warn-proprietary-attributes no -quiet -modify
- name: "Archive Pages Artifact"
uses: actions/upload-artifact@v4
with:
name: pages
path: |
.
!.git*/**