-
Notifications
You must be signed in to change notification settings - Fork 187
[WIP] Decouple examples gallery from the main repository #251
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b901f09
Pull sphinx-gallery from external repository
aperezhortal baedcdd
Update examples repository target branch
aperezhortal 88f9b50
Remove references to jupyter notebooks from comments
aperezhortal 2a27b3e
Update example gallery's URL in documentation
aperezhortal 3780450
Place the task to find the destination branch in a separate step
aperezhortal b6bd7c0
Add the event branch name to the triggering commit message
aperezhortal cfa5a7b
Allow the external_gallery to trigger the rendering action
aperezhortal 080d46a
Improve variables and task names
aperezhortal c4e4aef
Update commit message
aperezhortal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
.github/workflows/execute_tutorial_notebooks_in_external_repo.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| ######################################################################################## | ||
| # Trigger the notebooks' execution in the external repository. | ||
| # | ||
| # If the "main" branch triggered this event, then the nb execution is triggered in the | ||
| # "main" branch, otherwise in the dev branch. | ||
| # | ||
| # Naming convention used in this workflow: | ||
| # | ||
| # "main repository": Project repository with the python package and the documentation. | ||
| # "linked repository": Repository where the example gallery of jupyter notebooks is | ||
| # stored. | ||
| ######################################################################################## | ||
| name: Trigger notebook execution in the external repository | ||
|
|
||
| env: | ||
| # URL for the external repository linked with the notebooks in this project. | ||
| LINKED_REPO: pysteps/pysteps_tutorials | ||
|
dnerini marked this conversation as resolved.
Outdated
|
||
| THIS_REPO: pysteps/pysteps | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, dev ] | ||
| pull_request: | ||
| branches: [ main, dev ] | ||
|
dnerini marked this conversation as resolved.
Outdated
|
||
|
|
||
| jobs: | ||
| trigger_nb_execution: | ||
| name: Trigger the execution in the external repository with the notebooks | ||
| # The triggering is done by pushing an empty commit to the linked repository. | ||
| # The commit message contains the Hash of the main repository's commit that | ||
| # trigger the event. | ||
| runs-on: "ubuntu-latest" | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
|
|
||
| steps: | ||
| - name: Find the branch that trigger the event | ||
| id: get_dest_branch | ||
| run: | | ||
| if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then | ||
| event_branch=$(echo ${GITHUB_REF##*/}) | ||
| elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | ||
| event_branch=$(echo $GITHUB_BASE_REF) | ||
| else | ||
| event_branch=unknown | ||
| fi | ||
| echo "::set-output name=event_branch::${event_branch}" | ||
|
|
||
| # We only push to latest or to dev. | ||
| if [[ "${event_branch}" == "main" ]]; then | ||
| echo "::set-output name=dest_branch::main" | ||
| else | ||
| echo "::set-output name=dest_branch::dev" | ||
| fi | ||
|
|
||
| - name: Print debug information | ||
| env: | ||
| DEST_BRANCH: ${{steps.get_dest_branch.outputs.dest_branch}} | ||
| EVENT_BRANCH: ${{steps.get_dest_branch.outputs.event_branch}} | ||
| run: | | ||
| echo "EVENT_BRANCH=${EVENT_BRANCH}" | ||
| echo "GITHUB_SHA=${GITHUB_SHA}" | ||
| echo "DEST_BRANCH=${DEST_BRANCH}" | ||
|
|
||
| - name: Clone linked repository | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| persist-credentials: false # Avoid using the GITHUB_TOKEN instead of the personal access token | ||
| fetch-depth: 0 # Avoid errors pushing refs to the destination repository. | ||
| repository: ${{ env.LINKED_REPO }} | ||
| ref: ${{steps.get_dest_branch.outputs.dest_branch}} | ||
|
|
||
| - name: Create empty commit in linked repo | ||
| run: | | ||
| git config user.name 'github-actions[bot]' | ||
| git config user.email 'github-actions[bot]@users.noreply.github.com' | ||
| git commit --allow-empty \ | ||
| -m "Triggering nb execution from ${GITHUB_SHA::8}" \ | ||
| -m "https://github.com/${THIS_REPO}/commit/{$GITHUB_SHA}" | ||
|
|
||
| - name: Push the empty commit to trigger the workflow | ||
| uses: ad-m/github-push-action@master | ||
| with: | ||
| repository: ${{ env.LINKED_REPO }} | ||
| github_token: ${{ secrets.LINKED_TOKEN }} | ||
| branch: ${{steps.get_dest_branch.outputs.dest_branch}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,3 +85,6 @@ venv.bak/ | |
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
| /doc/source/user_guide/examples_gallery/ | ||
| /doc/source/examples_gallery/ | ||
| /examples/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,3 @@ sphinx_rtd_theme | |
| sphinx_gallery | ||
| scikit-image | ||
| pandas | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this idea! So, did I understand correctly that all branches but master will automatically render into "dev"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. However, right now only the main branch is pull in the examples repo. I will add something to pull the same branch that sent the triggering commit to the external repo. In that way, we can test if the examples execute correctly with development branches.