Skip to content

[WIP] Add workflow to mirror badge SVG to gh-pages branch#19

Closed
Copilot wants to merge 1 commit into
masterfrom
copilot/add-badge-svg-workflow
Closed

[WIP] Add workflow to mirror badge SVG to gh-pages branch#19
Copilot wants to merge 1 commit into
masterfrom
copilot/add-badge-svg-workflow

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 19, 2026

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/rdtool

Goal

  • Eliminate browser DevTools SameSite cookie warnings on GitHub Pages caused by embedding the GitHub Actions badge served from github.com, by serving an equivalent badge SVG from the same origin (uwabami.github.io).

Context

  • GitHub Pages is served from the gh-pages branch.
  • Pages paths:
    • Redirects exist via jekyll-redirect plugin:
      • index.htmlsoftware/rdtool/index.html
      • index.en.htmlsoftware/rdtool/index.en.html
  • Current badge URL embedded in Pages:
    • https://github.com/uwabami/rdtool/actions/workflows/test.yml/badge.svg
  • The workflow file is test.yml and its name: is Tests.

Implementation requirements

  1. Add a GitHub Actions workflow in the default branch (master) that mirrors the badge SVG into the gh-pages branch:

    • Trigger on completion of the Tests workflow using workflow_run and types: [completed].
    • Also include workflow_dispatch manual trigger.
    • Checkout the gh-pages branch.
    • Download the badge via curl -L.
    • Save it to software/rdtool/badges/test.svg in the checked-out gh-pages working tree.
    • Commit and push only if the file content changed.
    • Use permissions: contents: write.
    • Configure git author as github-actions[bot].
    • Use appropriate concurrency to avoid overlapping pushes.
  2. Update the Pages content (in gh-pages) to use the mirrored badge URL (same-origin) instead of the GitHub-hosted badge:

    • Replace any references to https://github.com/uwabami/rdtool/actions/workflows/test.yml/badge.svg with either:
      • absolute: https://uwabami.github.io/software/rdtool/badges/test.svg, or
      • relative (preferred when appropriate): badges/test.svg (for pages under software/rdtool/).
    • Ensure both Japanese and English Pages (software/rdtool/index.html / software/rdtool/index.en.html or their source equivalents) show the badge via the mirrored path.
  3. Ensure docs remain compatible with Jekyll build used by GitHub Pages.

Acceptance criteria

  • After merge, when Tests workflow completes, the mirror workflow updates gh-pages/software/rdtool/badges/test.svg automatically.
  • GitHub Pages pages under https://uwabami.github.io/software/rdtool/ display the badge correctly using the mirrored SVG.
  • The browser no longer needs to request the badge from github.com when rendering the Pages site, avoiding the SameSite cookie warnings from that embed.

Notes

  • The mirror workflow should be added under .github/workflows/ in the default branch (master).
  • If existing Pages files do not currently embed the badge, add it in a minimal, appropriate place.
  • If you need to locate where the badge is referenced, search the gh-pages branch 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.svg
  • または https://github.com/<owner>/<repo>/workflows/<name>/badge.svg

これを GitHub Pages(https://<user>.github.io/...)に <img> 等で埋め込むと、ブラウザから見ると

  • ページの “サイト” は github.io
  • 画像の取得先は github.com

という クロスサイトになります。

そのとき github.com 側が何らかの Cookie を返す/参照しようとすると、最近のブラウザは

  • 「クロスサイト文脈では SameSite ルールで送られない」
  • 「ブロックした/今後ブロックする」
    のような 警告を DevTools に出します

これはページ側で SameSite=None; Secure を付け替える、といった操作はできません(Cookie は発行元ドメインの管理)。


2) “解消” の現実的な選択肢

A. 実害がないなら「無視」が正解になりがち

badge が普通に表示されていて、ただコンソールに警告が出ているだけなら、実務上はそれで終わりにすることが多いです。

  • GitHub の実装(github.com 側)が変わらない限り、あなたが完全に消すのは困難です。

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 から配信できれば、ブラウザ的にはクロスサイトになりにくくなり、警告も抑えやすいです。

典型的には:

  1. GitHub Actions の workflow で badge.svg を取得(curl などでダウンロード)
  2. それを Pages の配信対象(docs/gh-pages ブランチ)にコミットして配置
  3. 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.

Copilot AI requested a review from uwabami March 19, 2026 20:45
Copilot stopped work on behalf of uwabami due to an error March 19, 2026 20:45
@uwabami uwabami closed this Mar 19, 2026
@uwabami uwabami deleted the copilot/add-badge-svg-workflow branch March 19, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants