Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for using the action in Org repos #4

Merged
merged 18 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 86 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,62 +40,92 @@ This action helps in the automation of a deployment strategy mentioned in [platf
- **Kedro-project dependencies:** Install all the Kedro-project dependencies before using this action in your workflow.
- **Python-version:** You need to have an environment with `python>=3.9` in your workflow.

**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).
> [!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 (recommended).
> 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.

> [!TIP]
> 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).

> [!Important]
> From `publish-kedro-viz@v2`, we only support custom GitHub Actions workflow as a publishing source for GitHub Pages.

## Usage

```yaml
1. With `kedro-org/publish-kedro-viz@v2`:

- uses: kedro-org/publish-kedro-viz@v1
with:
# The GitHub token to authenticate deployment. This is autogenerated by the action.
# Default: ${{ github.token }}
github_token: ''
```yaml

# The Kedro-project path to build the Kedro-Viz artifacts.
# Default: '.'
project_path: ''
- uses: kedro-org/publish-kedro-viz@v2
with:
# The Kedro-project path to build the Kedro-Viz artifacts.
# Default: '.'
project_path: ''

# The flag to include hooks while creating your Kedro-project build artifacts.
# Default: false
include_hooks: ''
# The flag to include hooks while creating your Kedro-project build artifacts.
# Default: false
include_hooks: ''

# Your consent to participate in Kedro-Telemetry.
# Default: true
telemetry_consent: ''

# Your consent to participate in Kedro-Telemetry.
# Default: true
telemetry_consent: ''

# The publishing source for GitHub pages. This can be either
# 'branch' or 'workflow' based on your GitHub Pages configuration
# Default: 'branch'
publishing_source: ''

# The GitHub pages publish branch to upload the artifacts
# if your publishing_source is a branch
# Default: 'gh-pages'
publish_branch: ''

# The commit message for the deployment, if your publishing_source is a branch.
# Defaults to your original commit message.
# Default: ${{ github.event.head_commit.message }}
commit_message: ''

# An option to publish branch with only the latest commit
# if your publishing_source is a branch.
# Default: true
force_orphan: ''

# The git config user.name or the owner of the commit.
# if your publishing_source is a branch.
# Default: 'github-actions[bot]'
user_name: ''

# The git config user.email or the email of the commit owner.
# if your publishing_source is a branch.
# Default: 'github-actions[bot]@users.noreply.github.com'
user_email: ''

```
```

2. With `kedro-org/publish-kedro-viz@v1`:

```yaml

- uses: kedro-org/publish-kedro-viz@v1
with:
# The GitHub token to authenticate deployment. This is autogenerated by the action.
# Default: ${{ github.token }}
github_token: ''

# The Kedro-project path to build the Kedro-Viz artifacts.
# Default: '.'
project_path: ''

# The flag to include hooks while creating your Kedro-project build artifacts.
# Default: false
include_hooks: ''

# Your consent to participate in Kedro-Telemetry.
# Default: true
telemetry_consent: ''

# The publishing source for GitHub pages. This can be either
# 'branch' or 'workflow' based on your GitHub Pages configuration
# Default: 'branch'
ravi-kumar-pilla marked this conversation as resolved.
Show resolved Hide resolved
publishing_source: ''

# The GitHub pages publish branch to upload the artifacts
# if your publishing_source is a branch
# Default: 'gh-pages'
publish_branch: ''

# The commit message for the deployment, if your publishing_source is a branch.
# Defaults to your original commit message.
# Default: ${{ github.event.head_commit.message }}
commit_message: ''

# An option to publish branch with only the latest commit
# if your publishing_source is a branch.
# Default: true
force_orphan: ''

# The git config user.name or the owner of the commit.
# if your publishing_source is a branch.
# Default: 'github-actions[bot]'
user_name: ''

# The git config user.email or the email of the commit owner.
# if your publishing_source is a branch.
# Default: 'github-actions[bot]@users.noreply.github.com'
user_email: ''

```

## Configure the action

Expand All @@ -105,7 +135,8 @@ This action helps in the automation of a deployment strategy mentioned in [platf
2. Add the following code to the workflow file:

```yaml
# An example workflow configuration
# An example workflow configuration assuming your kedro project is
# at the root directory

# The name of your workflow
name: Publish and share Kedro Viz
Expand Down Expand Up @@ -148,35 +179,29 @@ This action helps in the automation of a deployment strategy mentioned in [platf
- name: Install Project Dependencies
run: |
python -m pip install --upgrade pip
# This is not required if your Kedro Project
# is at the root of your GitHub Repository
cd demo-project
pip install -r requirements.txt
# Using the action
- name: Deploy Kedro-Viz to GH Pages
uses: kedro-org/publish-kedro-viz@v1
with:
# This is not required if your Kedro Project
# is at the root of your GitHub Repository
project_path: 'demo-project'
uses: kedro-org/publish-kedro-viz@v2

```

## Test the action

After you've completed the configuration, trigger the workflow as per the workflow trigger condition.

- 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.
- 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.
- 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.
- You can access the static site at `http://<username>.github.io/<repo-name>`
- If your GitHub Pages publishing source is a custom GitHub Actions workflow (recommended), then the artifacts of your Kedro-Viz static site will be uploaded and deployed during the workflow run-time.
ravi-kumar-pilla marked this conversation as resolved.
Show resolved Hide resolved
- 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. Please note that starting from v2, we will not support GitHub Pages publishing source as a branch.
- You can access the static site at `http://<username>.github.io/<repo-name>`, if your site's visibility is public. For more information on changing the visibility, you can follow the [official docs](https://docs.github.com/en/enterprise-cloud@latest/pages/getting-started-with-github-pages/changing-the-visibility-of-your-github-pages-site)

## Credits

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.

### Deploy to GitHub Pages when publishing source is a branch

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.
We use the GitHub action [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) in v1, to deploy the static site to a publish branch which is released under MIT license.

### Deploy to GitHub Pages when publishing source is a custom GitHub Action Workflow

Expand Down
7 changes: 7 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Release 2.0.0:

## Major features and improvements

- Remove usage of `peaceiris/actions-gh-pages`
- Update README file

# Release 1.1.0:

## Major features and improvements
Expand Down
44 changes: 3 additions & 41 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ branding:
color: yellow

inputs:
github_token:
description: "Set a GitHub token to authenticate deployment. This is autogenerated by the action."
required: false
default: ${{ github.token }}
project_path:
description: "Set your Kedro-project path to build the Kedro-Viz artifacts."
required: false
Expand All @@ -23,30 +19,6 @@ inputs:
description: "Set your consent if you would like to participate in Kedro-Telemetry. Defaults to false"
required: false
default: false
publishing_source:
description: "Set a publishing source for GitHub pages. Defaults to branch"
required: false
default: "branch"
publish_branch:
description: "Set a GitHub pages publish branch. Defaults to gh-pages"
required: false
default: "gh-pages"
commit_message:
description: "Set a commit message for the deployment. Defaults to your original commit message."
required: false
default: ${{ github.event.head_commit.message }}
force_orphan:
description: "Set an option to publish branch with only the latest commit. Defaults to true"
required: false
default: true
user_name:
description: "Set git config user.name. Defaults to github-actions[bot]"
required: false
default: "github-actions[bot]"
user_email:
description: "Set git config user.email. Defaults to github-actions[bot]@users.noreply.github.com"
required: false
default: "github-actions[bot]@users.noreply.github.com"

runs:
using: "composite"
Expand Down Expand Up @@ -76,22 +48,12 @@ runs:
exit 1
fi
shell: bash
- name: Deploy to GitHub Pages with publish branch as source
if: ${{ inputs.publishing_source == 'branch' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ inputs.github_token }}
publish_branch: ${{ inputs.publish_branch }}
publish_dir: "${{ inputs.project_path }}/build"
user_name: ${{ inputs.user_name }}
user_email: ${{ inputs.user_email }}
commit_message: ${{ inputs.commit_message }}
force_orphan: ${{ inputs.force_orphan }}
- name: Upload GitHub Pages artifact
if: ${{ inputs.publishing_source == 'workflow' }}
uses: actions/upload-pages-artifact@v3
with:
name: github-pages-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
path: "${{ inputs.project_path }}/build"
- name: Deploy to GitHub Pages
if: ${{ inputs.publishing_source == 'workflow' }}
uses: actions/deploy-pages@v4
with:
artifact_name: github-pages-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}