-
Notifications
You must be signed in to change notification settings - Fork 22
feat: replace raw absolute links as part of start-exercise #109
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This pull request consolidates the GitHub Actions workflow for starting exercises by merging the update_readme job into the create_exercise job, and adds functionality to replace absolute image URLs in step files to point to the current repository instead of the template repository.
Changes:
- Consolidated
update_readmejob intocreate_exercisejob to reduce workflow complexity - Added find-and-replace step to update raw.githubusercontent.com URLs in
.github/steps/*.mdfiles - Updated commit step to include both README.md and step markdown files
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| find: 'raw\.githubusercontent\.com/${{ steps.get-template-repo.outputs.TEMPLATE_REPOSITORY }}/([a-f0-9]{40}|refs/heads/[^/]+)/' | ||
| replace: 'raw.githubusercontent.com/${{ github.repository }}/${{ github.ref }}/' |
Copilot
AI
Feb 2, 2026
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.
The regex pattern for finding URLs includes refs/heads/[^/]+, but raw.githubusercontent.com URLs do not use the refs/heads/ prefix in their paths. They use the format raw.githubusercontent.com/owner/repo/branch-name/path or raw.githubusercontent.com/owner/repo/commit-sha/path.
Additionally, the replacement uses github.ref which returns the full reference format (e.g., refs/heads/main), but raw.githubusercontent.com URLs expect just the branch name (e.g., main).
This will create invalid URLs like raw.githubusercontent.com/owner/repo/refs/heads/main/image.png instead of the correct raw.githubusercontent.com/owner/repo/main/image.png.
Consider using github.ref_name instead of github.ref in the replace pattern, and update the find pattern to match actual raw.githubusercontent.com URL formats. The find pattern should be something like: raw\.githubusercontent\.com/${{ steps.get-template-repo.outputs.TEMPLATE_REPOSITORY }}/[a-f0-9]{40}/ for commit SHAs or handle branch names without the refs/heads/ prefix.
| find: 'raw\.githubusercontent\.com/${{ steps.get-template-repo.outputs.TEMPLATE_REPOSITORY }}/([a-f0-9]{40}|refs/heads/[^/]+)/' | |
| replace: 'raw.githubusercontent.com/${{ github.repository }}/${{ github.ref }}/' | |
| find: 'raw\.githubusercontent\.com/${{ steps.get-template-repo.outputs.TEMPLATE_REPOSITORY }}/([a-f0-9]{40}|[^/]+)/' | |
| replace: 'raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/' |
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.
Good catch but not ideal
Would need to figure out a way to use github.ref_name when raw.githubusercontent is used with a branch name and github.ref when used with a permalink
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.
Or we just restrict ourselves to always use raw.githubusercontent pointing to a branch name instead of a commit but that is not ideal with PR's
| ref: ${{ env.EXERCISE_TOOLKIT_REF }} | ||
|
|
||
|
|
||
| - name: Build welcome message from template |
Copilot
AI
Feb 2, 2026
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.
This step has the same name as another step at line 103. While both build messages from templates, they serve different purposes (one for the issue description, one for the README). Consider using distinct names like "Build README from template" to improve clarity and make debugging easier.
| - name: Build welcome message from template | |
| - name: Build README from template |
| replace: 'raw.githubusercontent.com/${{ github.repository }}/${{ github.ref }}/' | ||
| include: '.github/steps/*.md' | ||
| regex: true | ||
|
|
Copilot
AI
Feb 2, 2026
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.
This line contains trailing whitespace. Consider removing it to maintain consistent code formatting.
| path: exercise-toolkit | ||
| ref: ${{ env.EXERCISE_TOOLKIT_REF }} | ||
|
|
||
|
|
Copilot
AI
Feb 2, 2026
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.
This line contains trailing whitespace. Consider removing it to maintain consistent code formatting.
Changes
This pull request streamlines the GitHub Actions workflow for starting an exercise by merging the previously separate "Update README" job into the "Create exercise issue" job. It also adds logic to update image URLs in step files and ensures that both the
README.mdand any step markdown files are committed together. These changes simplify the workflow and improve consistency in handling exercise resources.Workflow consolidation and simplification:
update_readmejob into thecreate_exercisejob, so that updating the README and creating the exercise issue now happen in a single job, reducing redundancy and improving maintainability. [1] [2]Step file and README updates:
.github/steps/*.mdfiles, ensuring that image references point to the correct repository and branch when exercises are started from a template.README.mdand all step markdown files in.github/steps/*.md, so all relevant documentation changes are committed together.Output and variable fixes:
issue_urltemplate variable to use the correct output from the current job steps instead of a removed job dependency.Checklist