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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions: {}
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read # checkout.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1
with:
bundler-cache: true
# Seed photos download from Wikimedia Commons on first use; cache them so
# the suite only hits the network when the photo set in lib/seeds.rb
# changes. Keyed without restore-keys on purpose: cache files are named by
# photo key, so a changed URL must miss and re-download rather than reuse
# a stale image.
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/domus/seeds
key: domus-seeds-${{ hashFiles('lib/seeds.rb') }}
- run: bundle exec rake test
- run: bundle exec rake check
build:
name: Build
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read # checkout
packages: write # push container image to GHCR
outputs:
image: ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: short-sha
run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value={{date 'YYYYMMDD'}}-${{ steps.short-sha.outputs.sha }}
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy to Fly.io
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read # checkout
environment: demo
concurrency:
group: fly-deploy
cancel-in-progress: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: superfly/flyctl-actions/setup-flyctl@63da3ecc5e2793b98a3f2519b3d75d4f4c11cec2 # master
- run: flyctl deploy --image "$NEEDS_BUILD_OUTPUTS_IMAGE"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
NEEDS_BUILD_OUTPUTS_IMAGE: ${{ needs.build.outputs.image }}