Skip to content

Commit 1b3556b

Browse files
CopilotFidelusAleksanderCopilot
authored
fix: use github blob urls for images instead of raw.githubusercontent to fix issues of unavailable images in private repositories (#112)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: FidelusAleksander <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 4a610f6 commit 1b3556b

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/start-exercise.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,29 @@ jobs:
9393
9494
- name: Find and replace image URLs in step files
9595
if: steps.get-template-repo.outputs.TEMPLATE_REPOSITORY != ''
96-
uses: jacobtomlinson/gha-find-replace@v3
96+
uses: actions/github-script@v8
97+
env:
98+
STEP_FILES_GLOB: .github/steps/*.md
9799
with:
98-
find: '\.\./images/'
99-
replace: 'https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/.github/images/'
100-
include: '.github/steps/*.md'
101-
regex: true
100+
script: |
101+
const fs = require('fs');
102+
103+
const globber = await glob.create(process.env.STEP_FILES_GLOB);
104+
const files = await globber.glob();
105+
106+
files.forEach(file => {
107+
const content = fs.readFileSync(file, 'utf8');
108+
109+
// Replace ../images/* links with GitHub blob URLs suffixed with ?raw=true.
110+
const updatedContent = content.replace(
111+
/\.\.\/images\/([^\s)"']+)/g,
112+
'https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/.github/images/$1?raw=true'
113+
);
114+
115+
if (content !== updatedContent) {
116+
fs.writeFileSync(file, updatedContent, 'utf8');
117+
}
118+
});
102119
103120
- name: Build welcome message from template
104121
id: build-issue-description

0 commit comments

Comments
 (0)