Deploy snapshot gallery to GitHub Pages on release
Assisted-by: Claude Opus 4.6 via Claude Code
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
new file mode 100644
index 0000000..ec26dd2
--- /dev/null
+++ b/.github/workflows/pages.yml
@@ -0,0 +1,38 @@
+name: Pages
+
+on:
+ release:
+ types: [published]
+
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+concurrency:
+ group: pages
+ cancel-in-progress: true
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ steps:
+ - uses: actions/checkout@v4
+ - uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+ - env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ mkdir -p gallery
+ gh release download "${{ github.event.release.tag_name }}" --pattern "snapshots.tar.gz" --output snapshots.tar.gz
+ tar xzf snapshots.tar.gz -C gallery
+ bundle exec rake "snapshots:gallery[gallery,gallery/index.html]"
+ - uses: actions/upload-pages-artifact@v3
+ with:
+ path: gallery
+ - id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/Rakefile b/Rakefile
index af555ab..6fd85f2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -170,6 +170,16 @@ namespace :snapshots do
Rake::Task["snapshots:diff"].invoke
system("open", File.join(Snapshots.cache_dir, "diff.html"))
end
+
+ desc "Generate gallery HTML from images in a directory"
+ task :gallery, [:images_dir, :output_path] do |_t, args|
+ require "ketchup/snapshots"
+
+ images_dir = args.fetch(:images_dir)
+ output_path = args.fetch(:output_path)
+ Snapshots.generate_gallery_html(images_dir: images_dir, output_path: output_path)
+ puts output_path
+ end
end
task default: %i[ test binstubs ]