-
Notifications
You must be signed in to change notification settings - Fork 2
135 lines (117 loc) · 4.12 KB
/
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
# Build and deploy the dataplane design documentation.
# Publish a new version of the docs for pushes to "main", or deploy a preview
# when the workflow runs for a Pull Request.
name: "docs.yml"
on:
pull_request: {}
push:
branches:
- "main"
merge_group:
types: ["checks_requested"]
workflow_dispatch:
inputs:
debug_enabled:
type: "boolean"
description: "Run with tmate enabled"
required: false
default: false
concurrency:
group: "${{ github.workflow }}:${{ github.event.pull_request.number || github.event.after }}"
cancel-in-progress: true
permissions:
contents: "read"
pages: "write"
id-token: "write"
pull-requests: "read"
statuses: "write"
jobs:
check_changes:
name: "Deduce required tests from code changes"
runs-on: "ubuntu-latest"
outputs:
docs: "${{ steps.changes.outputs.docs }}"
steps:
- name: "Checkout"
if: "${{ !github.event.pull_request }}"
uses: "actions/checkout@v4"
with:
persist-credentials: "false"
fetch-depth: "0"
- name: "Check code changes"
uses: "dorny/paths-filter@v3"
id: "changes"
with:
filters: |
docs:
- 'design-docs/**'
- '.github/workflows/docs.yml'
- 'scripts/dpdk-sys.env'
build:
name: "Build and deploy documentation"
needs: [ check_changes ]
if: "${{ needs.check_changes.outputs.docs == 'true' || github.event_name == 'workflow_dispatch' }}"
runs-on: "ubuntu-latest"
steps:
- name: "install rust"
uses: "dtolnay/rust-toolchain@stable"
- run: |
cargo install just
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Extract branch name"
shell: "bash"
run: |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: "extract_branch"
- name: "Extract git hash"
shell: "bash"
run: |
echo "git_hash=${GITHUB_SHA}" >> $GITHUB_OUTPUT
id: "extract_hash"
- name: "Build design docs"
run: |
just debug=true mdbook build
- name: "Copy design doc build to publish directory"
run: |
set -euxo pipefail
mkdir --parent "${{ github.workspace }}/publish/"
cp -r ./design-docs/src/mdbook/book "${{ github.workspace }}/publish/design-docs"
- name: "(Push) Setup Pages"
if: "${{ !github.event.pull_request && github.event_name != 'merge_group' }}"
uses: "actions/configure-pages@v5"
- name: "(Push) Upload design-docs"
if: "${{ !github.event.pull_request && github.event_name != 'merge_group' }}"
uses: "actions/upload-pages-artifact@v3"
with:
# Upload design-docs build directory content
path: 'publish/design-docs'
- name: "(Push) Deploy to GitHub Pages"
if: "${{ !github.event.pull_request && github.event_name != 'merge_group' }}"
id: "deployment"
uses: "actions/deploy-pages@v4"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: "(PR) Deploy documentation preview"
if: "${{ github.event.pull_request }}"
uses: "nwtgck/actions-netlify@v2"
with:
publish-dir: "${{ github.workspace }}/publish/design-docs"
alias: "preview-${{ github.event.number }}"
deploy-message: "${{ github.event.pull_request.title }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
fails-without-credentials: "true"
enable-commit-status: "true"
enable-pull-request-comment: "false"
enable-commit-comment: "false"
enable-github-deployment: "false"
env:
NETLIFY_AUTH_TOKEN: "${{ secrets.NETLIFY_AUTH_TOKEN }}"
NETLIFY_SITE_ID: "${{ secrets.NETLIFY_SITE_ID }}"
timeout-minutes: 5
- name: "Setup tmate session for debug"
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: "mxschmitt/action-tmate@v3"
timeout-minutes: 60
with:
limit-access-to-actor: true