@@ -14,7 +14,7 @@ type Github = ReturnType<typeof getOctokit>;
1414
1515async function loadArticleFile (
1616 github : Github , folderName : string ,
17- ) : Promise < { rawUrl : string , content : string } > {
17+ ) : Promise < { fileName : string , content : string } > {
1818 const { owner, repo } = context . repo ;
1919 // NOTE: Pagination returns 30 files by default
2020 const commit = (
@@ -34,7 +34,7 @@ async function loadArticleFile(
3434 const newArticle = mdFiles [ 0 ] ;
3535 core . debug ( `Using ${ newArticle . filename ! } ` ) ;
3636 const content = await fs . readFile ( `./${ newArticle . filename ! } ` , 'utf8' ) ;
37- return { rawUrl : newArticle . raw_url ! , content } ;
37+ return { fileName : newArticle . filename ! , content } ;
3838}
3939
4040export async function run ( ) {
@@ -49,7 +49,12 @@ export async function run() {
4949 const github = getOctokit ( ghToken ) ;
5050
5151 const articleFile = await loadArticleFile ( github , articlesFolder ) ;
52- const baseUrl = path . dirname ( articleFile . rawUrl ) ;
52+ const rawGithubUrl = context . serverUrl
53+ . replace ( '//github.com' , '//raw.githubusercontent.com' ) ;
54+ const { repo, owner } = context . repo ;
55+ const branchName = context . ref . replace ( 'refs/heads/' , '' ) ;
56+ const fileUrl = `${ rawGithubUrl } /${ owner } /${ repo } /${ branchName } /${ articleFile . fileName } ` ;
57+ const baseUrl = path . dirname ( fileUrl ) ;
5358 /* istanbul ignore next */
5459 core . debug ( `Base URL: ${ baseUrl } ` ) ;
5560 const article = parseArticle ( articleFile . content , `${ baseUrl } /` ) ;
0 commit comments