[WIP] Add workflow to mirror badge SVG to gh-pages branch#19
Closed
Copilot wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
Repository:
uwabami/rdtoolGoal
github.com, by serving an equivalent badge SVG from the same origin (uwabami.github.io).Context
gh-pagesbranch.jekyll-redirectplugin:index.html→software/rdtool/index.htmlindex.en.html→software/rdtool/index.en.htmlhttps://github.com/uwabami/rdtool/actions/workflows/test.yml/badge.svgtest.ymland itsname:isTests.Implementation requirements
Add a GitHub Actions workflow in the default branch (
master) that mirrors the badge SVG into thegh-pagesbranch:Testsworkflow usingworkflow_runandtypes: [completed].workflow_dispatchmanual trigger.gh-pagesbranch.curl -L.software/rdtool/badges/test.svgin the checked-outgh-pagesworking tree.permissions: contents: write.github-actions[bot].concurrencyto avoid overlapping pushes.Update the Pages content (in
gh-pages) to use the mirrored badge URL (same-origin) instead of the GitHub-hosted badge:https://github.com/uwabami/rdtool/actions/workflows/test.yml/badge.svgwith either:https://uwabami.github.io/software/rdtool/badges/test.svg, orbadges/test.svg(for pages undersoftware/rdtool/).software/rdtool/index.html/software/rdtool/index.en.htmlor their source equivalents) show the badge via the mirrored path.Ensure docs remain compatible with Jekyll build used by GitHub Pages.
Acceptance criteria
Testsworkflow completes, the mirror workflow updatesgh-pages/software/rdtool/badges/test.svgautomatically.https://uwabami.github.io/software/rdtool/display the badge correctly using the mirrored SVG.github.comwhen rendering the Pages site, avoiding the SameSite cookie warnings from that embed.Notes
.github/workflows/in the default branch (master).gh-pagesbranch content.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: github actions の status を表示する badge をリポジトリの github pages にも表示したいのですが、Cookie Policy が SamteSite Lax or Strict となり、開発者ツールのコンソールで警告が出ます。github.com と ユーザ名.github.io なので、まあそうだよな、とは思うものの、これを解消することはできませんか?
Assistant: 結論から言うと、GitHub Actions の badge を
username.github.io(GitHub Pages)側に表示したときに出る「Cookie の SameSite=Lax/Strict」系の警告は、基本的にあなた(ページ側)では解消できません。理由はその Cookie がgithub.comドメインが発行している Cookie で、username.github.ioは別サイト(別 “site” / 別 eTLD+1)扱いになるため、ブラウザのクロスサイト制限に引っかかるからです。ただし、実害(表示が壊れる等)があるか/単なる警告かで対応が変わるので、現実的な落としどころを整理します。
1) なぜ警告が出るのか(起きていること)
GitHub Actions badge は通常、Markdown でこういう URL を参照します(例):
https://github.com/<owner>/<repo>/actions/workflows/<workflow>.yml/badge.svghttps://github.com/<owner>/<repo>/workflows/<name>/badge.svgこれを GitHub Pages(
https://<user>.github.io/...)に<img>等で埋め込むと、ブラウザから見るとgithub.iogithub.comという クロスサイトになります。
そのとき
github.com側が何らかの Cookie を返す/参照しようとすると、最近のブラウザはのような 警告を DevTools に出します。
これはページ側で
SameSite=None; Secureを付け替える、といった操作はできません(Cookie は発行元ドメインの管理)。2) “解消” の現実的な選択肢
A. 実害がないなら「無視」が正解になりがち
badge が普通に表示されていて、ただコンソールに警告が出ているだけなら、実務上はそれで終わりにすることが多いです。
B. badge を “github.com” ではなく “githubusercontent.com” / “raw” 側に寄せる(可能なら)
一部の GitHub 提供アセットは
*.githubusercontent.com経由だと Cookie 依存が減って警告が減る場合がありますが、Actions badge の URL は通常 github.com 起点で、簡単に差し替えられないことが多いです(リダイレクト先を直接使えるかはケース依存)。※「あなたのケースで badge.svg が最終的にどこへリダイレクトされているか」によって変わるので、ここは確認が必要です。
C. 自前で badge を “同一オリジン配信” する(警告を消す最有力)
Pages 側で
badge.svgを 同じusername.github.ioから配信できれば、ブラウザ的にはクロスサイトになりにくくなり、警告も抑えやすいです。典型的には:
badge.svgを取得(curl などでダウンロード)docs/やgh-pagesブランチ)にコミットして配置https://<user>.github.io/.../badge.svgを参照この方式だと ブラウザが
github.comへ画像を取りに行かないので、Cookie の警告自体が出なくなります(または大幅に減ります)。デメリットは、badge 更新が CI 依存になることと、更新頻度(push 時/定期)を設計する必要がある点です。
D. 画像を埋め込む先を “README(github.com 上)に限定” する
Pa...
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.