Skip to content

Commit 8ef1731

Browse files
PR builds include a live preview (Qiskit#55)
Closes Qiskit#3. We use the same open source workflow we use with qiskit.org and qiskit-sphinx-theme. We only preview the docs for PRs built directly on this repository, not for forks. That is a security restriction due to how forks work.
1 parent 06b2cf7 commit 8ef1731

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

.github/workflows/preview-docs.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This Action builds the docs in pull requests so that we can view a live preview.
2+
# It uses IBM Cloud to build the Dockerfile at the root of the repository.
3+
#
4+
# Due to security, this can only run on branches of qiskit/docs, i.e. not on forks.
5+
# We skip the actions if running on a fork.
6+
7+
name: Preview
8+
9+
on:
10+
pull_request:
11+
types: [opened, reopened, synchronize, closed]
12+
13+
jobs:
14+
setup:
15+
if: |
16+
(github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') &&
17+
github.event.pull_request.head.repo.full_name == github.repository
18+
uses: Qiskit/gh-actions/.github/workflows/code-engine-preview.yml@main
19+
with:
20+
code_engine_project: qiskit-docs-preview
21+
docker_image_name: qiskit-docs-preview
22+
docker_image_port: "3000"
23+
secrets:
24+
ibmcloud_account: ${{ secrets.IBMCLOUD_ACCOUNT }}
25+
ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
26+
27+
teardown:
28+
if: |
29+
github.event.action == 'closed' &&
30+
github.event.pull_request.head.repo.full_name == github.repository
31+
uses: Qiskit/gh-actions/.github/workflows/code-engine-cleanup.yml@main
32+
with:
33+
code_engine_project: qiskit-docs-preview
34+
docker_image_name: qiskit-docs-preview
35+
secrets:
36+
ibmcloud_account: ${{ secrets.IBMCLOUD_ACCOUNT }}
37+
ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This code is a Qiskit project.
2+
#
3+
# (C) Copyright IBM 2023.
4+
#
5+
# This code is licensed under the Apache License, Version 2.0. You may
6+
# obtain a copy of this license in the LICENSE file in the root directory
7+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Any modifications or derivative works of this code must retain this
10+
# copyright notice, and modified files need to carry a notice indicating
11+
# that they have been altered from the originals.
12+
13+
# This Dockerfile is used to preview the docs in pull requests via GitHub Actions.
14+
#
15+
# Keep it in sync with ./start. This Dockerfile essentially is the same,
16+
# only it sets the CLI args directly in the Dockerfile because the
17+
# GitHub Action expects that.
18+
#
19+
# To test it out locally:
20+
#
21+
# 1. ❯ docker build -t qiskit-docs-preview .
22+
# 2. ❯ docker run --rm -p 3000:3000 -t qiskit-docs-preview
23+
# 3. Open up http://localhost:3000
24+
25+
FROM icr.io/quantum-computing/iqp-channel-docs-dev
26+
27+
COPY docs/ /home/node/app/docs
28+
COPY public/images /home/node/app/public/images
29+
30+
EXPOSE 3000 5001

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ npm install
3333

3434
Run `./start` in your terminal, then open http://localhost:3000 in your browser.
3535

36+
## Preview the docs in PRs
37+
38+
Contributors with write access to this repository can use live previews of the docs: GitHub will deploy a website using your changes.
39+
40+
To use live previews, push your branch to `upstream` rather than your fork. GitHub will leave a comment with the link to the site. Please prefix your branch name with your initials, e.g. `EA/fix-build-typo`, for good Git hygiene.
41+
3642
## Spellcheck
3743

3844
We use [cSpell](https://cspell.org) to check for spelling. The `lint` job in CI will fail if there are spelling issues.

start

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# copyright notice, and modified files need to carry a notice indicating
1212
# that they have been altered from the originals.
1313

14+
# Keep this in sync with the Dockerfile at the root of the repository.
1415
docker run \
1516
-v "$(pwd)"/docs:/home/node/app/docs \
1617
-v "$(pwd)"/public/images:/home/node/app/public/images \

0 commit comments

Comments
 (0)