1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Preview
on:
pull_request:
types: [opened, reopened, synchronize, closed]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_REGION: sjc
FLY_ORG: personal
jobs:
snapshots:
name: Snapshots
if: github.event.action != 'closed'
runs-on: macos-latest
permissions:
contents: read # checkout and download baseline from release
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1
with:
bundler-cache: true
- name: Capture snapshot diff
run: |
bundle exec rake snapshots:diff
snapshot_dir="${XDG_CACHE_HOME:-$HOME/.cache}/ketchup/snapshots"
tar czf snapshots.tar.gz -C "$snapshot_dir" .
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: snapshots
path: snapshots.tar.gz
preview:
name: Preview
needs: snapshots
if: always()
runs-on: ubuntu-latest
permissions:
contents: read # checkout
concurrency:
group: pr-${{ github.event.number }}
environment:
name: pr-${{ github.event.number }}
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- if: github.event.action != 'closed'
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: snapshots
- name: Unpack snapshots into public/
if: github.event.action != 'closed'
run: |
mkdir -p public/snapshots
tar xzf snapshots.tar.gz -C public/snapshots
cp public/favicon.svg public/snapshots/
- uses: superfly/flyctl-actions/setup-flyctl@63da3ecc5e2793b98a3f2519b3d75d4f4c11cec2 # master
- name: Deploy preview
id: deploy
uses: superfly/fly-pr-review-apps@f5d85309215d5700e7a42faf9aa5e9a718aaef7c # 1.5.0
with:
config: fly.preview.toml
memory: 256