Repository navigation
106 lines (92 loc) · 2.97 KB
/
Copy pathdocker.yml
File metadata and controls
106 lines (92 loc) · 2.97 KB
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
99
100
101
102
103
104
105
106
name: Release Docker Image
on:
push:
tags:
- "v*"
permissions:
contents: read
packages: write
concurrency:
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
name: Publish Docker image to GHCR
runs-on: ubuntu-latest
environment: release
timeout-minutes: 30
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mammoth_e2e
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d mammoth_e2e"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Install native extension headers
run: |
sudo apt-get update
sudo apt-get install -y libsqlite3-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0.5"
bundler-cache: true
- name: Check tag matches gem version
if: startsWith(github.ref, 'refs/tags/')
run: |
version="$(ruby -Ilib -rmammoth/version -e 'puts Mammoth::VERSION')"
tag="${GITHUB_REF_NAME#v}"
if [ "$tag" != "$version" ]; then
echo "Tag v$tag does not match gem version $version"
exit 1
fi
- name: Run quality gates
run: bundle exec rake
- name: Enable PostgreSQL logical replication
run: |
docker exec "${{ job.services.postgres.id }}" psql -U postgres -d mammoth_e2e -c "ALTER SYSTEM SET wal_level = 'logical'"
docker restart "${{ job.services.postgres.id }}"
until docker exec "${{ job.services.postgres.id }}" pg_isready -U postgres -d mammoth_e2e; do sleep 1; done
- name: Run E2E tests
run: bundle exec rake test:e2e
env:
MAMMOTH_E2E_POSTGRES_URL: postgres://postgres:postgres@127.0.0.1:5432/mammoth_e2e
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/kanutocd/mammoth
tags: |
type=ref,event=tag
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build and publish Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./docker/Dockerfile
push: true
provenance: mode=max
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}