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] workflow notebook colab path #478

Merged
merged 1 commit into from
Feb 2, 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
26 changes: 5 additions & 21 deletions .github/workflows/build_main_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,12 @@ jobs:
- name: Convert notebooks to markdown files
if: inputs.convert_notebooks
run: |
initial_work_dir=$(pwd)
cd ${{ env.doc_folder }}
remote_url=$(git remote get-url origin)
trimmed_url=${remote_url#https://}
trimmed_url=${trimmed_url#github.com/}
trimmed_url=${trimmed_url%.git}
current_branch=$(git branch --show-current)
cd $initial_work_dir

directory_string="${{ env.doc_folder }}"
if [[ "$directory_string" == *"/"* ]]; then
# directory_string contains "/"
remaining_part=${directory_string#*/}
if [[ -n $remaining_part ]]; then
remaining_part="/$remaining_part"
fi
else
# directory_string does not contain "/"
remaining_part=""
fi
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
remaining_part=$(echo "${{ env.doc_folder }}" | perl -pe 's|^[^/]+||')
remaining_part=${remaining_part%/}
echo https://colab.research.google.com/github/${{ inputs.repo_owner }}/${{ inputs.package }}/blob/$branch$remaining_part

doc-builder notebook-to-mdx ${{ env.doc_folder }} --open_notebook_prefix https://colab.research.google.com/github/$trimmed_url/blob/$current_branch$remaining_part
doc-builder notebook-to-mdx ${{ env.doc_folder }} --open_notebook_prefix https://colab.research.google.com/github/${{ inputs.repo_owner }}/${{ inputs.package }}/blob/$branch$remaining_part

- name: Make documentation
shell: bash
Expand Down
26 changes: 5 additions & 21 deletions .github/workflows/build_pr_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,12 @@ jobs:
- name: Convert notebooks to markdown files
if: inputs.convert_notebooks
run: |
initial_work_dir=$(pwd)
cd ${{ env.doc_folder }}
remote_url=$(git remote get-url origin)
trimmed_url=${remote_url#https://}
trimmed_url=${trimmed_url#github.com/}
trimmed_url=${trimmed_url%.git}
current_branch=$(git branch --show-current)
cd $initial_work_dir

directory_string="${{ env.doc_folder }}"
if [[ "$directory_string" == *"/"* ]]; then
# directory_string contains "/"
remaining_part=${directory_string#*/}
if [[ -n $remaining_part ]]; then
remaining_part="/$remaining_part"
fi
else
# directory_string does not contain "/"
remaining_part=""
fi
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
remaining_part=$(echo "${{ env.doc_folder }}" | perl -pe 's|^[^/]+||')
remaining_part=${remaining_part%/}
echo https://colab.research.google.com/github/${{ inputs.repo_owner }}/${{ inputs.package }}/blob/$branch$remaining_part

doc-builder notebook-to-mdx ${{ env.doc_folder }} --open_notebook_prefix https://colab.research.google.com/github/$trimmed_url/blob/$current_branch$remaining_part
doc-builder notebook-to-mdx ${{ env.doc_folder }} --open_notebook_prefix https://colab.research.google.com/github/${{ inputs.repo_owner }}/${{ inputs.package }}/blob/$branch$remaining_part

- name: Make documentation
env:
Expand Down
Loading