Skip to content

Commit a0d58fa

Browse files
authored
Merge pull request #149 from rstudio/mbh-docs-publish
Sync docs to s3 on latest + release
2 parents e8534f2 + e9492d1 commit a0d58fa

File tree

6 files changed

+82
-24
lines changed

6 files changed

+82
-24
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,46 @@ jobs:
157157
runs-on: ubuntu-latest
158158
steps:
159159
- uses: actions/checkout@v2
160+
- run: git fetch --prune --unshallow
161+
- uses: actions/setup-python@v2
162+
with:
163+
python-version: 3.8.x
164+
- uses: actions/cache@v1
165+
with:
166+
path: ~/.cache/pip
167+
key: pip-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }}
168+
restore-keys: |
169+
pip-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }}
170+
pip-ubuntu-latest-py3.8-
171+
- uses: actions/cache@v1
172+
with:
173+
path: ~/.local/share/virtualenvs
174+
key: virtualenvs-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }}
175+
restore-keys: |
176+
virtualenvs-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }}
177+
virtualenvs-ubuntu-latest-py3.8-
178+
- run: pip install -U pipenv pip
179+
- run: make deps
160180
- run: make docs
161181
- uses: actions/upload-artifact@v2
162182
with:
163183
name: docs
164184
path: docs/site/
185+
- uses: aws-actions/configure-aws-credentials@v1
186+
with:
187+
aws-access-key-id: ${{ secrets.AWS_ID }}
188+
aws-secret-access-key: ${{ secrets.AWS_SECRET }}
189+
aws-region: us-east-1
190+
- if: github.event_name == 'push' && github.ref == 'refs/heads/master'
191+
run: make sync-latest-docs-to-s3
192+
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
193+
uses: aws-actions/configure-aws-credentials@v1
194+
with:
195+
aws-access-key-id: ${{ secrets.DOCS_AWS_ID }}
196+
aws-secret-access-key: ${{ secrets.DOCS_AWS_SECRET }}
197+
aws-region: us-east-1
198+
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
199+
run: make promote-docs-in-s3
165200
dispatch:
166201
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
167202
needs: distributions

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
VERSION := $(shell pipenv run python setup.py --version)
22
HOSTNAME := $(shell hostname)
3-
BDIST_WHEEL := dist/rsconnect_python-$(VERSION)-py2.py3-none-any.whl
43
S3_PREFIX := s3://rstudio-connect-downloads/connect/rsconnect-python
54

5+
BDIST_WHEEL := dist/rsconnect_python-$(VERSION)-py2.py3-none-any.whl
6+
67
RUNNER = docker run \
78
-it --rm \
89
-v $(PWD):/rsconnect \
@@ -125,7 +126,7 @@ fmt: fmt-3.8
125126

126127
.PHONY: docs
127128
docs:
128-
$(MAKE) -C docs
129+
$(MAKE) -C docs VERSION=$(VERSION)
129130

130131
.PHONY: version
131132
version:
@@ -154,3 +155,17 @@ sync-latest-to-s3:
154155
--cache-control max-age=0 \
155156
$(BDIST_WHEEL) \
156157
$(S3_PREFIX)/latest/rsconnect_python-latest-py2.py3-none-any.whl
158+
159+
.PHONY: sync-latest-docs-to-s3
160+
sync-latest-docs-to-s3:
161+
aws s3 sync --delete --acl bucket-owner-full-control \
162+
--cache-control max-age=0 \
163+
docs/site/ \
164+
$(S3_PREFIX)/latest/docs/
165+
166+
.PHONY: promote-docs-in-s3
167+
promote-docs-in-s3:
168+
aws s3 sync --delete --acl bucket-owner-full-control \
169+
--cache-control max-age=300 \
170+
docs/site/ \
171+
s3://docs.rstudio.com/rsconnect-python/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,7 @@ to enable later redeployment. This data is stored alongside the deployed file,
499499
in an `rsconnect-python` subdirectory, if possible. If that location is not writable
500500
during deployment, then the deployment data will be stored in the global configuration
501501
directory specified above.
502+
503+
<div style="display:none">
504+
Generated from <code>rsconnect-python {{ rsconnect_python.version }}</code>
505+
</div>

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8.2-alpine3.11
1+
FROM python:3.8-slim
22
MAINTAINER RStudio Connect <[email protected]>
33

44
# Needed with Python3 mkdocs.

docs/Makefile

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# Our make file for the docs.
2-
MKDOCS_IMAGE?="rstudio/rsconnect:mkdocs"
1+
MKDOCS_IMAGE ?= rstudio/rsconnect:mkdocs
2+
VERSION ?= NOTSET
33

4-
## Specify that Docker runs with the calling user's uid/gid to avoid file
5-
## permission issues on Linux dev hosts.
6-
DOCKER_RUN_AS=
4+
DOCKER_RUN_AS =
75
ifeq (Linux,$(shell uname))
8-
DOCKER_RUN_AS=-u $(shell id -u):$(shell id -g)
6+
DOCKER_RUN_AS = -u $(shell id -u):$(shell id -g)
97
endif
108

11-
BUILD_RUNNER=docker run --rm --name mkdocs \
12-
${DOCKER_RUN_AS} \
13-
-v $(CURDIR):/mkdocs \
14-
-w /mkdocs \
15-
${MKDOCS_IMAGE}
9+
BUILD_RUNNER = \
10+
docker run --rm --name mkdocs \
11+
$(DOCKER_RUN_AS) \
12+
-e VERSION=$(VERSION) \
13+
-v $(CURDIR):/mkdocs \
14+
-w /mkdocs \
15+
$(MKDOCS_IMAGE)
1616

17-
# Do everything,
17+
.PHONY: all
1818
all: clean image build
1919

20-
# Destroy the site, if it exists.
20+
.PHONY: clean
2121
clean:
22-
@rm -rf docs/site
22+
rm -rf docs/site
2323

24-
# Build the image in which mkdocs will run.
24+
.PHONY: image
2525
image:
26-
docker build -t ${MKDOCS_IMAGE} .
26+
docker build -t $(MKDOCS_IMAGE) .
2727

28-
# Build the actual documentation.
29-
build:
30-
python patch_admonitions.py
31-
${BUILD_RUNNER} mkdocs build
28+
.PHONY: build
29+
build: docs/index.md
30+
$(BUILD_RUNNER) mkdocs build
3231
@rm docs/index.md
3332

34-
.PHONY: clean image build
33+
docs/index.md: $(CURDIR)/../README.md
34+
python patch_admonitions.py

docs/mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ theme:
2222

2323
extra_css:
2424
- css/custom.css
25+
26+
extra:
27+
rsconnect_python:
28+
version: !!python/object/apply:os.getenv ["VERSION"]

0 commit comments

Comments
 (0)