diff --git a/.github/workflows/delete-preview.yaml b/.github/workflows/delete-preview.yaml deleted file mode 100644 index 2123ac2..0000000 --- a/.github/workflows/delete-preview.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: delete-preview - -# Only run this when the main branch changes -on: - pull_request_target: - types: closed - -jobs: - delete: - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - steps: - - name: Checkout gh-pages branch - uses: actions/checkout@v3 - with: - ref: gh-pages - - name: Delete preview files - run: | - rm -rf _preview/${{ github.event.pull_request.number }} - - name: Commit the changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: gh-pages - commit_message: Delete preview for pull request \#${{ github.event.pull_request.number }} diff --git a/.github/workflows/deploy-book.yaml b/.github/workflows/deploy-book.yaml deleted file mode 100644 index 8b55021..0000000 --- a/.github/workflows/deploy-book.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: deploy-book - -on: - # Trigger the workflow on push to main branch - push: - branches: - - main - workflow_dispatch: - -jobs: - build: - uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/build-book.yaml@main - with: - environment_name: cookbook-dev - environment_file: environment.yml - path_to_notebooks: ./ - use_cached_environment: 'true' - - deploy: - needs: build - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - steps: - - name: Download Artifact Book - uses: actions/download-artifact@v3 - with: - name: book-zip-${{ github.event.number }} - - - name: Unzip the book - run: | - rm -rf _build/html - unzip book.zip - rm -f book.zip - - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3.8.0 - if: github.ref == 'refs/heads/main' - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _build/html - keep_files: true # This preserves existing previews from open PRs diff --git a/.github/workflows/deploy-preview.yaml b/.github/workflows/deploy-preview.yaml deleted file mode 100644 index ee8462d..0000000 --- a/.github/workflows/deploy-preview.yaml +++ /dev/null @@ -1,137 +0,0 @@ -name: deploy-preview -on: - workflow_run: - workflows: - - trigger-book-build - types: - - requested - - completed - -jobs: - deploy: - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v3 - - name: Fetch Repo Name - id: repo-name - run: echo "::set-output name=value::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" # just the repo name, not owner - - - name: Set message value - run: | - echo "comment_message=👋 Thanks for opening this PR! The Cookbook will be automatically built with [GitHub Actions](https://github.com/features/actions). To see the status of your deployment, click below." >> $GITHUB_ENV - - - name: Find Pull Request - uses: actions/github-script@v6 - id: find-pull-request - with: - script: | - let pullRequestNumber = '' - let pullRequestHeadSHA = '' - core.info('Finding pull request...') - const pullRequests = await github.rest.pulls.list({owner: context.repo.owner, repo: context.repo.repo}) - for (let pullRequest of pullRequests.data) { - if(pullRequest.head.sha === context.payload.workflow_run.head_commit.id) { - pullRequestHeadSHA = pullRequest.head.sha - pullRequestNumber = pullRequest.number - break - } - } - core.setOutput('number', pullRequestNumber) - core.setOutput('sha', pullRequestHeadSHA) - if(pullRequestNumber === '') { - core.info( - `No pull request associated with git commit SHA: ${context.payload.workflow_run.head_commit.id}` - ) - } - else{ - core.info(`Found pull request ${pullRequestNumber}, with head sha: ${pullRequestHeadSHA}`) - } - - - name: Find preview comment - uses: peter-evans/find-comment@v2 - if: steps.find-pull-request.outputs.number != '' - id: fc - with: - issue-number: '${{ steps.find-pull-request.outputs.number }}' - comment-author: 'github-actions[bot]' - body-includes: '${{ env.comment_message }}' - - - name: Create preview comment - if: | - github.event.workflow_run.conclusion != 'success' - && steps.find-pull-request.outputs.number != '' - && steps.fc.outputs.comment-id == '' - uses: peter-evans/create-or-update-comment@v2 - with: - issue-number: ${{ steps.find-pull-request.outputs.number }} - body: | - ${{ env.comment_message }} - 🔍 Git commit SHA: ${{ steps.find-pull-request.outputs.sha }} - ✅ Deployment Preview URL: In Progress - - - name: Update preview comment - if: | - github.event.workflow_run.conclusion != 'success' - && steps.find-pull-request.outputs.number != '' - && steps.fc.outputs.comment-id != '' - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - edit-mode: replace - body: | - ${{ env.comment_message }} - 🔍 Git commit SHA: ${{ steps.find-pull-request.outputs.sha }} - ✅ Deployment Preview URL: In Progress - - - name: Download Artifact Book - if: | - github.event.workflow_run.conclusion == 'success' - && steps.find-pull-request.outputs.number != '' - && steps.fc.outputs.comment-id != '' - uses: dawidd6/action-download-artifact@v2.23.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - workflow: build-book.yaml - run_id: ${{ github.event.workflow_run.id }} - name: book-zip-${{ steps.find-pull-request.outputs.number }} - - - name: Unzip the book - if: | - github.event.workflow_run.conclusion == 'success' - && steps.find-pull-request.outputs.number != '' - && steps.fc.outputs.comment-id != '' - run: | - rm -rf _build/html - unzip book.zip - rm -f book.zip - - # Push the book's HTML to github-pages - # This will be published at /_preview/PRnumber/ relative to the main site - - name: Deploy to GitHub pages - if: | - github.event.workflow_run.conclusion == 'success' - && steps.find-pull-request.outputs.number != '' - && steps.fc.outputs.comment-id != '' - uses: peaceiris/actions-gh-pages@v3.8.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _build/html - enable_jekyll: false - destination_dir: _preview/${{ steps.find-pull-request.outputs.number }} - - - name: Finalize preview comment - if: | - github.event.workflow_run.conclusion == 'success' - && steps.find-pull-request.outputs.number != '' - && steps.fc.outputs.comment-id != '' - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - edit-mode: replace - body: | - ${{ env.comment_message }} - 🔍 Git commit SHA: ${{ steps.find-pull-request.outputs.sha }} - ✅ Deployment Preview URL: https://${{ github.repository_owner }}.github.io/${{ steps.repo-name.outputs.value }}/_preview/${{ steps.find-pull-request.outputs.number }} diff --git a/.github/workflows/nightly-build.yaml b/.github/workflows/nightly-build.yaml index 28956ca..00c7a4e 100644 --- a/.github/workflows/nightly-build.yaml +++ b/.github/workflows/nightly-build.yaml @@ -7,15 +7,12 @@ on: jobs: build: + if: ${{ github.repository_owner == 'ProjectPythiaCookbooks' }} uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/build-book.yaml@main with: - environment_name: cookbook-dev - environment_file: environment.yml - path_to_notebooks: ./ + environment_name: intake-cookbook-dev link-check: + if: ${{ github.repository_owner == 'ProjectPythiaCookbooks' }} uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/link-checker.yaml@main - with: - environment_name: cookbook-dev - environment_file: environment.yml - path_to_notebooks: ./ + \ No newline at end of file diff --git a/.github/workflows/publish-book.yaml b/.github/workflows/publish-book.yaml new file mode 100644 index 0000000..3a88fb2 --- /dev/null +++ b/.github/workflows/publish-book.yaml @@ -0,0 +1,19 @@ +name: publish-book + +on: + # Trigger the workflow on push to main branch + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/build-book.yaml@main + with: + environment_name: intake-cookbook-dev + + deploy: + needs: build + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/deploy-book.yaml@main + \ No newline at end of file diff --git a/.github/workflows/trigger-book-build.yaml b/.github/workflows/trigger-book-build.yaml index f33a14c..7c7cdb8 100644 --- a/.github/workflows/trigger-book-build.yaml +++ b/.github/workflows/trigger-book-build.yaml @@ -6,14 +6,6 @@ jobs: build: uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/build-book.yaml@main with: - environment_name: cookbook-dev - environment_file: environment.yml - path_to_notebooks: ./ - use_cached_environment: 'true' # This is default, not strickly needed. Set to 'false' to always build a new environment - link-check: - uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/link-checker.yaml@main - with: - environment_name: cookbook-dev - environment_file: environment.yml - path_to_notebooks: ./ - use_cached_environment: 'true' + environment_name: intake-cookbook-dev + artifact_name: book-zip-${{ github.event.number }} + # Other input options are possible, see ProjectPythiaCookbooks/cookbook-actions/.github/workflows/build-book.yaml diff --git a/.github/workflows/trigger-delete-preview.yaml b/.github/workflows/trigger-delete-preview.yaml new file mode 100644 index 0000000..b070fe9 --- /dev/null +++ b/.github/workflows/trigger-delete-preview.yaml @@ -0,0 +1,9 @@ +name: trigger-delete-preview + +on: + pull_request_target: + types: closed + +jobs: + delete: + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/delete-preview.yaml@main \ No newline at end of file diff --git a/.github/workflows/trigger-link-check.yaml b/.github/workflows/trigger-link-check.yaml new file mode 100644 index 0000000..7ea9999 --- /dev/null +++ b/.github/workflows/trigger-link-check.yaml @@ -0,0 +1,8 @@ +name: trigger-link-check +on: + pull_request: + +jobs: + link-check: + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/link-checker.yaml@main + \ No newline at end of file diff --git a/.github/workflows/trigger-preview.yaml b/.github/workflows/trigger-preview.yaml new file mode 100644 index 0000000..1a94e5d --- /dev/null +++ b/.github/workflows/trigger-preview.yaml @@ -0,0 +1,27 @@ +name: trigger-preview +on: + workflow_run: + workflows: + - trigger-book-build + types: + - requested + - completed + +jobs: + find-pull-request: + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/find-pull-request.yaml@main + deploy-preview: + needs: find-pull-request + if: github.event.workflow_run.conclusion == 'success' + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/deploy-book.yaml@main + with: + artifact_name: book-zip-${{ needs.find-pull-request.outputs.number }} + destination_dir: _preview/${{ needs.find-pull-request.outputs.number }} # deploy to subdirectory labeled with PR number + is_preview: 'true' + + preview-comment: + needs: find-pull-request + uses: ProjectPythiaCookbooks/cookbook-actions/.github/workflows/preview-comment.yaml@main + with: + pull_request_number: ${{ needs.find-pull-request.outputs.number }} + sha: ${{ needs.find-pull-request.outputs.sha }} diff --git a/README.md b/README.md index fff2953..1d2df70 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # Intake Cookbook [![nightly-build](https://github.com/ProjectPythiaCookbooks/intake-cookbook/actions/workflows/nightly-build.yaml/badge.svg)](https://github.com/ProjectPythiaCookbooks/intake-cookbook/actions/workflows/nightly-build.yaml) -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ProjectPythiaCookbooks/intake-cookbook/main?labpath=notebooks) +[![Binder](http://binder.mypythia.org/badge_logo.svg)](http://binder.mypythia.org/v2/gh/ProjectPythiaCookbooks/intake-cookbook/main?labpath=notebooks) This Project Pythia Cookbook covers using and creating Intake catalogs to access data. diff --git a/_config.yml b/_config.yml index 6161bd9..f055fef 100644 --- a/_config.yml +++ b/_config.yml @@ -57,7 +57,7 @@ sphinx: icon: fab fa-youtube-square type: fontawesome launch_buttons: - binderhub_url: https://mybinder.org + binderhub_url: http://binder.mypythia.org notebook_interface: jupyterlab extra_navbar: | Theme by Project Pythia.