-
Notifications
You must be signed in to change notification settings - Fork 21
154 lines (138 loc) · 5.72 KB
/
ci.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Build and push
on:
push:
pull_request:
schedule:
- cron: "0 0 * * 0"
jobs:
base-images:
# for security reason, we only build these images in our repository and on the main branch
if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
flavor:
- alpine
- bookworm
pg_version:
- "9.5"
- "9.6"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
- "16"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.flavor }}"
push: true
platforms: linux/amd64,linux/arm64
build-args: |
"PGTARGET=16"
target: "build-${{ matrix.pg_version }}"
tags: "pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}-${{ matrix.flavor }}"
cache-to: type=inline
cache-from: type=registry,ref=pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}-${{ matrix.flavor }}
target-images:
runs-on: ubuntu-latest
needs: base-images
# otherwise, it would skip the build entirely (because the base step does not run)
if: always()
env:
# but still use our public caches in any case
# they might be outdated, in which case a full rebuild will be triggered
CACHE_FROM: |
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-10-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-11-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-12-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-13-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-14-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-15-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-16-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }}
strategy:
matrix:
operating_system:
- flavor: "alpine"
version: "3.20"
- flavor: "bookworm"
pg_target:
- "12"
- "13"
- "14"
- "15"
- "16"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.repository == 'pgautoupgrade/docker-pgautoupgrade'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build image
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system.flavor }}"
load: true
tags: |
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }}"
build-args: |
"PGTARGET=${{ matrix.pg_target }}"
cache-to: type=inline
cache-from: "${{ env.CACHE_FROM }}"
- name: Checkout code
uses: actions/checkout@v4
- name: Test image
run: |
make test
env:
PGTARGET: ${{ matrix.pg_target }}
OS_FLAVOR: ${{ matrix.operating_system.flavor }}
- name: Push image
if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system.flavor }}"
platforms: linux/amd64,linux/arm64
tags: |
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }}"
build-args: |
"PGTARGET=${{ matrix.pg_target }}"
push: true
cache-to: type=inline
cache-from: "${{ env.CACHE_FROM }}"
- name: Push latest image
if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main' && matrix.pg_target == '16' && matrix.operating_system.flavor == 'alpine'
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system.flavor }}"
platforms: linux/amd64,linux/arm64
tags: |
"pgautoupgrade/pgautoupgrade:latest"
build-args: |
"PGTARGET=${{ matrix.pg_target }}"
push: true
cache-to: type=inline
cache-from: "${{ env.CACHE_FROM }}"