fix: use github blob urls for images instead of raw.githubusercontent to fix issues of unavailable images in private repositories#112
Conversation
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
|
@copilot i got this error Unhandled error: SyntaxError: Identifier 'glob' has already been declared some of these libraries are already loaded by github-script |
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
|
@copilot i'm getting this error now "Unhandled error: TypeError: glob.glob is not a function" Make sure you research which libraries github-script imports and how to use them |
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
|
The replacement isn't ideal - here is an example was replaced with <img width="300" alt="search box with 'python' value" src="https://github.com/FidelusAleksander/test-github-raw/blob/main/.github/images/python-search-box.png"?raw=true /> the |
Co-authored-by: FidelusAleksander <63016446+FidelusAleksander@users.noreply.github.com>
Fixed. Updated the regex pattern from |
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable “Start Exercise” workflow to rewrite step-file image links to GitHub blob URLs (with ?raw=true) instead of raw.githubusercontent.com, using actions/github-script to support regex capture groups.
Changes:
- Replaced
jacobtomlinson/gha-find-replace@v3withactions/github-script@v8for image URL rewriting. - Implemented a JavaScript-based regex replacement that preserves closing delimiters for Markdown/HTML image syntax.
- Introduced
STEP_FILES_GLOBenv var to parameterize which step markdown files are processed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>


Changes
Migrates image URL structure in the start-exercise workflow from
raw.githubusercontent.comto GitHub blob URLs with?raw=trueparameter.Replaced action in
.github/workflows/start-exercise.yml:The implementation now uses
actions/github-script@v8instead ofjacobtomlinson/gha-find-replace@v3because the latter does not support regex capture groups in replacement strings.The implementation uses the pre-loaded
globmodule fromactions/github-scriptwhich is@actions/glob. The correct API requires two steps: first create a globber withawait glob.create(pattern), then retrieve files withawait globber.glob().The regex pattern
/\.\.\/images\/([^\s)"']+)/gcaptures the image filename while excluding whitespace, quotes, and parentheses. This ensures?raw=trueis correctly placed before closing delimiters in both Markdown syntaxand HTML syntax<img src="../images/file.png">.URL transformation:
../images/my-image.pnghttps://github.com/{repo}/blob/{ref}/.github/images/my-image.png?raw=trueSupported formats:
→<img src="../images/file.png">→<img src="https://github.com/{repo}/blob/{ref}/.github/images/file.png?raw=true"><img src='../images/file.png'>→<img src='https://github.com/{repo}/blob/{ref}/.github/images/file.png?raw=true'>Checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.