Skip to content

Commit 3cc2d8c

Browse files
committed
Filter RRN notebooks based on nexus_support flag in export_rrn_to_repo.py
1 parent bd99f84 commit 3cc2d8c

File tree

3 files changed

+22
-51
lines changed

3 files changed

+22
-51
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ jobs:
5656
contents: write
5757
pull-requests: write
5858
steps:
59-
- name: Install jq
60-
run: sudo apt-get update && sudo apt-get install -y jq
61-
6259
- name: Download site bundle
6360
uses: actions/download-artifact@v4
6461
with:
@@ -68,7 +65,7 @@ jobs:
6865
- name: Check out site repository
6966
uses: actions/checkout@v4
7067
with:
71-
repository: rges-pit/rges-pit.github.io-dc-copy
68+
repository: rges-pit/rges-pit.github.io
7269
token: ${{ secrets.SITE_SYNC_PAT }}
7370
path: site
7471

@@ -86,11 +83,10 @@ jobs:
8683
git config user.name "github-actions[bot]"
8784
git config user.email "github-actions[bot]@users.noreply.github.com"
8885
89-
# Use upstream main as base (read-only) and create/update branch on fork
90-
git remote add upstream https://github.com/rges-pit/rges-pit.github.io.git
91-
git fetch upstream main
92-
SYNC_BRANCH="chore/data-challenge-sync-dc-copy"
93-
git checkout -B "$SYNC_BRANCH" upstream/main
86+
# Create/update a branch on the upstream repo
87+
git fetch origin main
88+
SYNC_BRANCH="chore/data-challenge-sync"
89+
git checkout -B "$SYNC_BRANCH" origin/main
9490
9591
# Stage and Commit
9692
git add docs/_pages/
@@ -100,59 +96,30 @@ jobs:
10096
fi
10197
git commit -m "chore: sync data-challenge workshop pages"
10298
103-
# Push branch to fork (dc-copy)
99+
# Push branch to upstream
104100
git push -f origin "$SYNC_BRANCH"
105101
106-
# Create PR against upstream.
107-
# Use REST API so we can disambiguate same-owner forks via "<fork-repo>:<branch>".
108-
BASE_REPO_OWNER="rges-pit"
109-
BASE_REPO_NAME="rges-pit.github.io"
110-
HEAD_REPO_OWNER="rges-pit"
111-
HEAD_REPO_NAME="rges-pit.github.io-dc-copy"
102+
# Create PR against upstream (same repo)
103+
BASE_REPO="rges-pit/rges-pit.github.io"
112104
HEAD_BRANCH="$SYNC_BRANCH"
113105
BASE_BRANCH="main"
114106
PR_TITLE="Draft: Sync data-challenge notebooks"
115107
PR_BODY="Automated sync of generated workshop documentation from \`data-challenge-notebooks\`."
116108
117-
# Find an existing open PR from this fork branch.
118-
PULLS_JSON=$(gh api \
119-
--paginate \
120-
-H "Accept: application/vnd.github+json" \
121-
"/repos/$BASE_REPO_OWNER/$BASE_REPO_NAME/pulls?state=open&per_page=100")
122-
123-
EXISTING_PR=$(echo "$PULLS_JSON" | jq -r '.[] | select(.head.ref=="'"$HEAD_BRANCH"'" and .head.repo.name=="'"$HEAD_REPO_NAME"'") | .html_url' | head -n 1)
124-
if [ -n "$EXISTING_PR" ] && [ "$EXISTING_PR" != "null" ]; then
109+
EXISTING_PR=$(gh pr list --repo "$BASE_REPO" --head "$HEAD_BRANCH" --state open --json url --jq '.[0].url')
110+
if [ -n "$EXISTING_PR" ]; then
125111
echo "PR already exists: $EXISTING_PR"
126112
exit 0
127113
fi
128114
129115
echo "Creating new PR..."
130-
set +e
131-
CREATE_PR_JSON=$(gh api \
132-
-H "Accept: application/vnd.github+json" \
133-
-X POST \
134-
"/repos/$BASE_REPO_OWNER/$BASE_REPO_NAME/pulls" \
135-
-f title="$PR_TITLE" \
136-
-f body="$PR_BODY" \
137-
-f head="$HEAD_REPO_OWNER:$HEAD_BRANCH" \
138-
-f base="$BASE_BRANCH" \
139-
-F draft=true 2>&1)
140-
CREATE_STATUS=$?
141-
set -e
142-
143-
if [ $CREATE_STATUS -ne 0 ]; then
144-
echo "PR creation failed (exit $CREATE_STATUS). Full response:"
145-
echo "$CREATE_PR_JSON"
146-
exit 1
147-
fi
148-
149-
NEW_PR_URL=$(echo "$CREATE_PR_JSON" | jq -r '.html_url')
150-
if [ -z "$NEW_PR_URL" ] || [ "$NEW_PR_URL" = "null" ]; then
151-
echo "PR creation did not return a URL. Full response:"
152-
echo "$CREATE_PR_JSON" | jq -r '.'
153-
exit 1
154-
fi
155-
echo "Created PR: $NEW_PR_URL"
116+
gh pr create \
117+
--repo "$BASE_REPO" \
118+
--head "$HEAD_BRANCH" \
119+
--base "$BASE_BRANCH" \
120+
--title "$PR_TITLE" \
121+
--body "$PR_BODY" \
122+
--draft
156123
157124
nexus-publish:
158125
needs: build-pages

scripts/export_rrn_to_repo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def export_rrn_notebooks(
7575
# for requirements.txt placement).
7676
notebook_dirs: set[Path] = set()
7777
for entry in notebooks:
78+
if not entry.get("nexus_support", False):
79+
continue
7880
target = entry.get("rrn_target")
7981
nb_id = entry.get("id")
8082
if not nb_id or not target:
@@ -89,6 +91,8 @@ def export_rrn_notebooks(
8991
shutil.rmtree(nb_dir)
9092

9193
for entry in notebooks:
94+
if not entry.get("nexus_support", False):
95+
continue
9296
nb_id = entry.get("id")
9397
target = entry.get("rrn_target")
9498
if not nb_id or not target:

0 commit comments

Comments
 (0)