forked from zeek/zeek
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (126 loc) · 4.7 KB
/
generate-docs.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
135
136
137
138
139
140
141
142
143
name: Generate Documentation
on:
pull_request:
schedule:
- cron: '0 0 * * *'
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
generate:
permissions:
contents: write # for Git to git push
if: github.repository == 'zeek/zeek'
runs-on: ubuntu-latest
steps:
# We only perform a push if the action was triggered via a schedule
# event, so we only need to authenticate in that case. Use
# unauthenticated access otherwise so this action can e.g., also run from
# clones.
- uses: actions/checkout@v3
if: github.event_name == 'schedule'
with:
submodules: "recursive"
token: ${{ secrets.ZEEK_BOT_TOKEN }}
- uses: actions/checkout@v3
if: github.event_name != 'schedule'
with:
submodules: "recursive"
# Only reset the submodule pointer for scheduled builds. The reason to do
# this is to pick up any merge commits or anything that may have been
# missed in a merge, but not have any actual content. We don't want to do
# it otherwise because PRs should just use the submodule they're pointing
# at.
- name: Switch doc submodule to master
if: github.event_name == 'schedule'
run: cd doc && git checkout master
- name: Fetch Dependencies
run: |
sudo apt-get update
sudo apt-get -y install \
bison \
bsdmainutils \
ccache \
cmake \
flex \
g++ \
gcc \
git \
libfl-dev \
libfl2 \
libkrb5-dev \
libpcap-dev \
libssl-dev \
make \
python3 \
python3-dev \
python3-pip\
sqlite3 \
swig \
zlib1g-dev
# Many distros adhere to PEP 394's recommendation for `python` =
# `python2` so this is a simple workaround until we drop Python 2
# support and explicitly use `python3` for all invocations.
sudo ln -sf /usr/bin/python3 /usr/local/bin/python
sudo pip3 install -r doc/requirements.txt
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: 'docs-gen-${{ github.job }}'
max-size: '2000M'
- name: Configure
run: ./configure --disable-broker-tests --disable-cpp-tests --ccache
- name: Build
run: cd build && make -j $(nproc)
- name: Check Spicy docs
run: cd doc && make check-spicy-docs
- name: Generate Docs
run: |
git config --global user.name zeek-bot
git config --global user.email [email protected]
echo "*** Generating Zeekygen Docs ***"
./ci/update-zeekygen-docs.sh || exit 1
echo "*** Generating Sphinx Docs ***"
cd doc
make > make.out 2>&1
make_status=$?
echo "*** Sphinx Build Output ***"
cat make.out
test ${make_status} -ne 0 && exit 1
echo "*** Check for Sphinx Warnings ***"
grep -q WARNING make.out && exit 1
rm make.out
- name: Push zeek-docs Changes
if: github.event_name == 'schedule'
run: |
cd doc
git add scripts/ script-reference/
git status
# git commit errors when there's nothing to commit, so guard it
# with a check that detects whether there's anything staged.
git diff-index --cached --quiet HEAD || { git commit -m "Generate docs" && git push; }
- name: Update zeek-docs Submodule
if: github.event_name == 'schedule'
run: |
git config --global user.name zeek-bot
git config --global user.email [email protected]
git add doc
git status
# Similar logic here: proceed only if there's a change in the submodule.
git diff-index --cached --quiet HEAD || { git commit -m 'Update doc submodule [nomail] [skip ci]' && git push; }
- name: Send email
# Only send notifications for scheduled runs. Runs from pull requests
# show failures in the GitHub UI.
if: failure() && github.event_name == 'schedule'
uses: dawidd6/[email protected]
with:
server_address: ${{secrets.SMTP_HOST}}
server_port: ${{secrets.SMTP_PORT}}
username: ${{secrets.SMTP_USER}}
password: ${{secrets.SMTP_PASS}}
subject: generate-docs GitHub Action failed!
body: generate-docs job of ${{github.repository}} Failed! See https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} for details.
to: ${{secrets.MAIL_TO}}
from: GitHub Actions <${{secrets.MAIL_FROM}}>