Skip to content

Commit 3b01b3c

Browse files
authored
docs: enable mkdocs netlify build previews (#533)
2 parents 4dcc95b + 98d1d46 commit 3b01b3c

File tree

7 files changed

+81
-6
lines changed

7 files changed

+81
-6
lines changed

.devcontainer/compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ services:
1515
entrypoint: mkdocs
1616
command: serve --dev-addr "0.0.0.0:8001"
1717
ports:
18-
- "8001:8001"
18+
- 8001:8001
1919
volumes:
2020
- ../:/usr/src/calitp

.devcontainer/devcontainer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"dockerComposeFile": "compose.yml",
44
"service": "site",
55
"runServices": ["site", "docs"],
6-
"otherPortsAttributes": { "onAutoForward": "ignore" },
76
"workspaceFolder": "/usr/src/calitp",
87
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],
98
"customizations": {

.github/workflows/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

.github/workflows/mkdocs.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Publish docs
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
paths:
7+
- "docs/**"
8+
- "mkdocs.yml"
9+
- ".github/workflows/mkdocs.yml"
10+
11+
env:
12+
SANITIZED_REPO_NAME: "calitp-website"
13+
14+
jobs:
15+
docs-preview:
16+
name: Publish docs preview
17+
runs-on: ubuntu-latest
18+
# only pull requests should generate a preview
19+
if: github.event.pull_request
20+
permissions:
21+
pull-requests: write
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
with:
26+
ref: "refs/pull/${{ github.event.number }}/merge"
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v6
30+
with:
31+
python-version-file: .github/workflows/.python-version
32+
cache: pip
33+
cache-dependency-path: "docs/requirements.txt"
34+
35+
- name: Build MkDocs website
36+
run: |
37+
pip install -r docs/requirements.txt
38+
mkdocs build
39+
40+
# it would speeds this action up significantly to cache this
41+
- name: Install Netlify CLI
42+
run: npm install --location=global netlify-cli@23
43+
44+
- name: Deploy Preview to Netlify
45+
run: |
46+
netlify deploy \
47+
--alias="${SANITIZED_REPO_NAME}-${{ github.event.number }}" \
48+
--auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \
49+
--dir="site" \
50+
--site=${{ secrets.NETLIFY_PREVIEW_APP_SITE_ID }} \
51+
--no-build \
52+
53+
- name: Find existing comment
54+
uses: peter-evans/find-comment@v4
55+
id: find-comment
56+
with:
57+
issue-number: ${{ github.event.number }}
58+
comment-author: "github-actions[bot]"
59+
body-includes: "Preview url: https://"
60+
61+
- name: Add Netlify link PR comment
62+
uses: actions/github-script@v8
63+
if: steps.find-comment.outputs.comment-id == ''
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
script: |
67+
const hostnamePrefix = process.env.SANITIZED_REPO_NAME
68+
const hostnameSuffix = "cal-itp-previews.netlify.app"
69+
70+
github.rest.issues.createComment({
71+
issue_number: context.issue.number,
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
body: `Preview url: https://${hostnamePrefix}-${{ github.event.number }}--${hostnameSuffix}`,
75+
})

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.netlify
44
_site
55
.DS_Store
6+
site

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ We have a semi-automated way of handling resource requests that come in via GitH
4646
gh issue view <issue num> --json body | python .github/scripts/resource-template.py
4747
```
4848

49-
We have a GitHub Actions workflow that runs this script against all new issues and will automatically open a PR to add the requested resource, if the issue in fact appears to be a resource request and it is said to be approved. If an issue is opened initially for a resource that is not yet approved, the PR can be created automatically once the resource has been approved by going to [the workflow's page](https://github.com/cal-itp/calitp.org/actions/workflows/resource-template.yml) and using the **Run workflow** button.
49+
We have a GitHub Actions workflow that runs this script against all new issues and will automatically open a PR to add the requested resource, if the issue in fact appears to be a resource request and it is said to be approved. If an issue is opened initially for a resource that is not yet approved, the PR can be created automatically once the resource has been approved by going to [the workflow's page](./actions/workflows/resource-template.yml) and using the **Run workflow** button.
5050

5151
### Press
5252

mkdocs.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
site_name: "cal-itp/calitp-dot-org: documentation"
1+
site_name: "cal-itp/calitp.org: documentation"
22
repo_url: https://github.com/cal-itp/calitp.org
33
edit_uri: edit/dev/docs
4-
site_url: https://docs.calitp.org/calitp-dot-org
4+
site_url: https://docs.calitp.org/calitp.org
55
exclude_docs: |
66
**/inc/*.md
77
@@ -26,7 +26,6 @@ plugins:
2626

2727
extra_css:
2828
- styles/theme.css
29-
- https://use.fontawesome.com/releases/v5.13.0/css/all.css
3029

3130
markdown_extensions:
3231
- admonition

0 commit comments

Comments
 (0)