Skip to content

Commit fb1351c

Browse files
Merge pull request #1 from kedro-org/feature/viz-share-action
publish-kedro-viz action Initial Release
2 parents 6733593 + 3ce8d5b commit fb1351c

File tree

6 files changed

+312
-3
lines changed

6 files changed

+312
-3
lines changed

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This workflow is used to test the GitHub action publish-kedro-viz
2+
3+
name: Test publish-kedro-viz
4+
5+
permissions:
6+
contents: write
7+
pages: write
8+
id-token: write
9+
10+
on:
11+
push:
12+
branches:
13+
- "*"
14+
paths-ignore:
15+
- "*.md"
16+
pull_request:
17+
branches:
18+
- main
19+
workflow_dispatch:
20+
21+
jobs:
22+
test:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Fetch the repository
26+
uses: actions/checkout@v4
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.11"
31+
- name: Create a Kedro Project and install project dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install "kedro>=0.19.3"
35+
kedro new --starter=spaceflights-pandas-viz --name=demo-project
36+
cd demo-project
37+
pip install -r requirements.txt
38+
- name: Deploy Kedro-Viz to GH Pages
39+
uses: ./
40+
with:
41+
project_path: "demo-project"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# publish-kedro-viz
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]

LICENSE renamed to LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

README.md

Lines changed: 174 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,174 @@
1-
# kedro-viz-share
2-
Publish and share Kedro-Viz static website on GitHub pages in your workflow through this GitHub action
1+
# Publish-kedro-viz
2+
3+
![Kedro Logo Banner - Light](https://raw.githubusercontent.com/kedro-org/kedro/main/.github/demo-dark.png#gh-dark-mode-only)
4+
![Kedro Logo Banner - Dark](https://raw.githubusercontent.com/kedro-org/kedro/main/.github/demo-light.png#gh-light-mode-only)
5+
6+
<br />
7+
<p align="center">
8+
9+
![Kedro-Viz Pipeline Visualisation](https://raw.githubusercontent.com/kedro-org/kedro-viz/main/.github/img/banner.png)
10+
11+
</p>
12+
13+
<p align="center">
14+
✨ <em> Data Science Pipelines. Beautifully Designed</em> ✨
15+
<br />
16+
Live Demo: <a href="https://demo.kedro.org/" target="_blank">https://demo.kedro.org/</a>
17+
</p>
18+
19+
<br />
20+
21+
## Overview
22+
23+
Publish-kedro-viz is a GitHub action that simplifies the process of deploying Kedro-viz, which is a visual representation of your Kedro project, directly within the Git repository where your Kedro project is stored. By using this action, you can effortlessly showcase your Kedro-viz on GitHub Pages.
24+
25+
This action helps in the automation of a deployment strategy mentioned in [platform agnostic sharing with Kedro-Viz](https://docs.kedro.org/projects/kedro-viz/en/v8.0.1/platform_agnostic_sharing_with_kedro_viz.html#static-website-hosting-platforms-such-as-github-pages)
26+
27+
## Prerequisites
28+
29+
- **GitHub Repository:** A GitHub repository with your Kedro project.
30+
- **GitHub Pages Setup:** Configure your repository for [GitHub Pages](https://docs.github.com/en/pages/quickstart).
31+
- **Kedro-project dependencies:** Install all the Kedro-project dependencies before using this action in your workflow.
32+
- **Python-version:** You need to have an environment with `python>=3.9` in your workflow.
33+
34+
**NOTE:** While configuring your repository for GitHub Pages, you have two publishing source options. You can either choose a branch or a custom GitHub Actions workflow. If you choose a branch, the build artifacts will be uploaded to the `publish_branch` you pass as an input to the action, which defaults to `gh-pages`. If you choose a custom GitHub Actions workflow, you need to mention that in the input `publishing_source` to the action. In this case, no branch will be created and the artifacts are deployed at run-time. Please find more information on configuring a publishing source for github pages site in the [official docs](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site).
35+
36+
37+
## Usage
38+
39+
```yaml
40+
41+
- uses: kedro-org/publish-kedro-viz@v1
42+
with:
43+
# The GitHub token to authenticate deployment. This is autogenerated by the action.
44+
# Default: ${{ github.token }}
45+
github_token: ''
46+
47+
# The Kedro-project path to build the Kedro-Viz artifacts.
48+
# Default: '.'
49+
project_path: ''
50+
51+
# Your consent to participate in Kedro-Telemetry.
52+
# Default: true
53+
telemetry_consent: ''
54+
55+
# The publishing source for GitHub pages. This can be either
56+
# 'branch' or 'workflow' based on your GitHub Pages configuration
57+
# Default: 'branch'
58+
publishing_source: ''
59+
60+
# The GitHub pages publish branch to upload the artifacts
61+
# if your publishing_source is a branch
62+
# Default: 'gh-pages'
63+
publish_branch: ''
64+
65+
# The commit message for the deployment, if your publishing_source is a branch.
66+
# Defaults to your original commit message.
67+
# Default: ${{ github.event.head_commit.message }}
68+
commit_message: ''
69+
70+
# An option to publish branch with only the latest commit
71+
# if your publishing_source is a branch.
72+
# Default: true
73+
force_orphan: ''
74+
75+
# The git config user.name or the owner of the commit.
76+
# if your publishing_source is a branch.
77+
# Default: 'github-actions[bot]'
78+
user_name: ''
79+
80+
# The git config user.email or the email of the commit owner.
81+
# if your publishing_source is a branch.
82+
# Default: 'github-actions[bot]@users.noreply.github.com'
83+
user_email: ''
84+
85+
```
86+
87+
## Configure the action
88+
89+
1. Adding the GitHub Action to your workflow:
90+
91+
1. Create a workflow file in your repository: `.github/workflows/publish-kedro-viz.yml`
92+
2. Add the following code to the workflow file:
93+
94+
```yaml
95+
# An example workflow configuration
96+
97+
# The name of your workflow
98+
name: Publish and share Kedro Viz
99+
100+
permissions:
101+
102+
# The contents write permission is required to use the action
103+
# if your GitHub publishing source is a branch
104+
contents: write
105+
106+
# The pages and id-token write permissions are required to use
107+
# the action if your GitHub publishing source is a custom
108+
# GitHub Actions workflow
109+
pages: write
110+
id-token: write
111+
112+
on:
113+
# This can be configured based on your requirements
114+
# (i.e., the workflow trigger condition)
115+
pull_request:
116+
push:
117+
branches:
118+
- main
119+
workflow_dispatch:
120+
121+
# We mentioned the minimal jobs for the workflow
122+
jobs:
123+
deploy:
124+
# The action is currently tested on ubuntu-latest (Recommended)
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Fetch the repository
128+
uses: actions/checkout@v4
129+
- name: Set up Python
130+
uses: actions/setup-python@v5
131+
with:
132+
# Requires python >= 3.9
133+
python-version: 3.11
134+
# This installs the Kedro-project dependencies
135+
- name: Install Project Dependencies
136+
run: |
137+
python -m pip install --upgrade pip
138+
# This is not required if your Kedro Project
139+
# is at the root of your GitHub Repository
140+
cd demo-project
141+
pip install -r requirements.txt
142+
# Using the action
143+
- name: Deploy Kedro-Viz to GH Pages
144+
uses: kedro-org/publish-kedro-viz@v1
145+
with:
146+
# This is not required if your Kedro Project
147+
# is at the root of your GitHub Repository
148+
project_path: 'demo-project'
149+
```
150+
151+
## Test the action
152+
153+
After you've completed the configuration, trigger the workflow as per the workflow trigger condition.
154+
155+
- Once triggered, the GitHub workflow "Publish and share Kedro Viz" will automatically start and can be found in the Actions tab with your commit message.
156+
- If your GitHub Pages publishing source is a branch, then the artifacts of your Kedro-Viz static site will be uploaded to the publish-branch input specified in the action upon successful completion of the workflow.
157+
- If your GitHub Pages publishing source is a custom GitHub Actions workflow, then the artifacts of your Kedro-Viz static site will be uploaded and deployed during the workflow run-time.
158+
- You can access the static site at `http://<username>.github.io/<repo-name>`
159+
160+
## Credits
161+
162+
The list of third party actions used in this project, with due credits to their authors and license terms. More details can be found inside the folder of each action.
163+
164+
### Deploy to GitHub Pages when publishing source is a branch
165+
166+
We use the GitHub action [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) to deploy the static site to a publish branch which is released under MIT license.
167+
168+
### Deploy to GitHub Pages when publishing source is a custom GitHub Action Workflow
169+
170+
We use the GitHub actions [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) and [actions/deploy-pages](https://github.com/actions/deploy-pages) which are released under MIT license.
171+
172+
## License
173+
174+
publish-kedro-viz is licensed under the [Apache 2.0](https://github.com/kedro-org/publish-kedro-viz/blob/main/LICENSE.md) License.

RELEASE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Release 1.0.0:
2+
3+
This is an initial release of publish-kedro-viz action
4+
5+
## Major features and improvements
6+
7+
- Add initial setup for the action
8+
- Add `spaceflights-pandas-viz` Kedro starter to test the workflow
9+
- Update README file

action.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: publish-kedro-viz
2+
description: This is a GitHub action to publish kedro viz static website on GitHub Pages
3+
author: kedro-viz
4+
5+
branding:
6+
icon: share
7+
color: yellow
8+
9+
inputs:
10+
github_token:
11+
description: "Set a GitHub token to authenticate deployment. This is autogenerated by the action."
12+
required: false
13+
default: ${{ github.token }}
14+
project_path:
15+
description: "Set your Kedro-project path to build the Kedro-Viz artifacts."
16+
required: false
17+
default: "."
18+
telemetry_consent:
19+
description: "Set your consent if you would like to participate in Kedro-Telemetry. Defaults to false"
20+
required: false
21+
default: false
22+
publishing_source:
23+
description: "Set a publishing source for GitHub pages. Defaults to branch"
24+
required: false
25+
default: "branch"
26+
publish_branch:
27+
description: "Set a GitHub pages publish branch. Defaults to gh-pages"
28+
required: false
29+
default: "gh-pages"
30+
commit_message:
31+
description: "Set a commit message for the deployment. Defaults to your original commit message."
32+
required: false
33+
default: ${{ github.event.head_commit.message }}
34+
force_orphan:
35+
description: "Set an option to publish branch with only the latest commit. Defaults to true"
36+
required: false
37+
default: true
38+
user_name:
39+
description: "Set git config user.name. Defaults to github-actions[bot]"
40+
required: false
41+
default: "github-actions[bot]"
42+
user_email:
43+
description: "Set git config user.email. Defaults to github-actions[bot]@users.noreply.github.com"
44+
required: false
45+
default: "github-actions[bot]@users.noreply.github.com"
46+
47+
runs:
48+
using: "composite"
49+
steps:
50+
- name: Install Kedro-Viz
51+
run: |
52+
python -m pip install --upgrade pip
53+
python -m pip install "kedro-viz>=7.1.0"
54+
shell: bash
55+
- name: Consent to the use of Kedro-Telemetry
56+
run: |
57+
cd ${{ inputs.project_path }}
58+
echo 'consent: ${{ inputs.telemetry_consent }}' > .telemetry
59+
shell: bash
60+
- name: Create build directory
61+
run: |
62+
cd ${{ inputs.project_path }}
63+
if !(kedro viz build |& tee /dev/stderr | grep -i -q "Success!"); then
64+
exit 1
65+
fi
66+
shell: bash
67+
- name: Deploy to GitHub Pages with publish branch as source
68+
if: ${{ inputs.publishing_source == 'branch' }}
69+
uses: peaceiris/actions-gh-pages@v3
70+
with:
71+
github_token: ${{ inputs.github_token }}
72+
publish_branch: ${{ inputs.publish_branch }}
73+
publish_dir: "${{ inputs.project_path }}/build"
74+
user_name: ${{ inputs.user_name }}
75+
user_email: ${{ inputs.user_email }}
76+
commit_message: ${{ inputs.commit_message }}
77+
force_orphan: ${{ inputs.force_orphan }}
78+
- name: Upload GitHub Pages artifact
79+
if: ${{ inputs.publishing_source == 'workflow' }}
80+
uses: actions/upload-pages-artifact@v3
81+
with:
82+
path: "${{ inputs.project_path }}/build"
83+
- name: Deploy to GitHub Pages
84+
if: ${{ inputs.publishing_source == 'workflow' }}
85+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)