Skip to content
Closed
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
140 changes: 140 additions & 0 deletions .github/workflows/pr-pub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
on:
pull_request:
branches: [main]
types: [opened, synchronize, closed]

jobs:
deploy-preview:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup micromamba
if: github.event.action != 'closed'
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
init-shell: bash
cache-environment: true

- name: Setup Quarto
if: github.event.action != 'closed'
uses: quarto-dev/quarto-actions/setup@v2

- name: Get commit info
id: commit
run: |
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "full_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "commit_message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_OUTPUT

- name: Render Quarto Project
if: github.event.action != 'closed'
shell: micromamba-shell {0}
run: quarto render

- name: Deploy to GitHub Pages
if: github.event.action != 'closed'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
destination_dir: commit-${{ steps.commit.outputs.short_sha }}
keep_files: true

- name: Find existing preview comment
if: github.event.action != 'closed'
uses: actions/github-script@v6
id: find-comment
with:
script: |
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const previewComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('<!-- quarto-preview-comment -->')
);

return previewComment ? previewComment.id : null;

- name: Create or update preview comment
if: github.event.action != 'closed'
uses: actions/github-script@v6
with:
script: |
const shortSha = '${{ steps.commit.outputs.short_sha }}';
const fullSha = '${{ steps.commit.outputs.full_sha }}';
const commitMessage = '${{ steps.commit.outputs.commit_message }}';
const previewUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/commit-${shortSha}/`;
const commitUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${fullSha}`;
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;

const body = `<!-- quarto-preview-comment -->
## 📖 Quarto Preview

| | |
|---|---|
| **Latest commit** | [\`${shortSha}\`](${commitUrl}) |
| **Commit message** | ${commitMessage} |
| **Preview URL** | ${previewUrl} |
| **Build log** | [View workflow run](${runUrl}) |

> The preview will be updated automatically when you push new commits to this PR.`;

const commentId = ${{ steps.find-comment.outputs.result }};

if (commentId) {
await github.rest.issues.updateComment({
comment_id: commentId,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
}

- name: Clean up preview comment on PR close
if: github.event.action == 'closed'
uses: actions/github-script@v6
with:
script: |
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const previewComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('<!-- quarto-preview-comment -->')
);

if (previewComment) {
await github.rest.issues.updateComment({
comment_id: previewComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: `<!-- quarto-preview-comment -->
## 📖 Quarto Preview

~~Preview was removed when PR was closed.~~`
});
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _site/
example_data/
*.h5
*.nc
_freeze
15 changes: 9 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: nsidc_data_cookbook
channels:
- conda-forge
- default
dependencies:
- python ~=3.10

- python ~=3.13
###################################################
# Imported dependencies and extensions #
###################################################

- jupyterlab
- jupyterlab<=4.2
- matplotlib
- cartopy
- dask
Expand All @@ -18,7 +15,13 @@ dependencies:
- xarray
- rioxarray
- pandas
- geopandas
- pytest
- earthaccess
- h5py

- h5netcdf
- hvplot
- geoviews
- ipyleaflet
- virtualizarr
- fsspec
2 changes: 1 addition & 1 deletion tutorials/hdf5_formatting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"id": "e70aa9a5-58dc-44e7-a600-a1f9db2027d5",
"metadata": {},
"source": [
"Create some dimension variables. The dimension scales need to be in the group so that they can found by `xarray`."
"Create some dimension variables. The dimension scales need to be in the group so that they can found by `xarray`. -"
]
},
{
Expand Down
Loading