|
5 | 5 | branches:
|
6 | 6 | - develop
|
7 | 7 | paths:
|
8 |
| - - '.github/workflows/dockerhub-release.yml' |
9 |
| - - 'common.vars*' |
| 8 | + - ".github/workflows/dockerhub-release.yml" |
| 9 | + - "common.vars*" |
10 | 10 |
|
11 | 11 | jobs:
|
12 | 12 | settings:
|
13 |
| - runs-on: ubuntu-20.04 |
| 13 | + runs-on: ubuntu-latest |
14 | 14 | outputs:
|
15 | 15 | docker_version: ${{ steps.settings.outputs.postgres-version }}
|
| 16 | + image_tag: supabase/postgres:${{ steps.settings.outputs.postgres-version }} |
| 17 | + build_args: ${{ steps.args.outputs.result }} |
16 | 18 | steps:
|
17 | 19 | - uses: actions/checkout@v3
|
18 |
| - |
19 | 20 | - id: settings
|
20 | 21 | # Remove spaces and quotes to get the raw version string
|
21 | 22 | run: sed -r 's/(\s|\")+//g' common.vars.pkr.hcl >> $GITHUB_OUTPUT
|
| 23 | + - id: args |
| 24 | + uses: mikefarah/yq@master |
| 25 | + with: |
| 26 | + cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml' |
22 | 27 |
|
23 |
| - docker_x86_release: |
| 28 | + build_image: |
24 | 29 | needs: settings
|
25 |
| - runs-on: [self-hosted, X64] |
26 |
| - timeout-minutes: 120 |
27 |
| - env: |
28 |
| - arch: amd64 |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - runner: [self-hosted, X64] |
| 34 | + arch: amd64 |
| 35 | + - runner: arm-runner |
| 36 | + arch: arm64 |
| 37 | + runs-on: ${{ matrix.runner }} |
| 38 | + timeout-minutes: 180 |
29 | 39 | outputs:
|
30 | 40 | image_digest: ${{ steps.build.outputs.digest }}
|
31 | 41 | steps:
|
32 |
| - - uses: actions/checkout@v3 |
33 |
| - |
34 |
| - - id: meta |
35 |
| - uses: docker/metadata-action@v4 |
36 |
| - with: |
37 |
| - images: | |
38 |
| - supabase/postgres |
39 |
| - tags: | |
40 |
| - type=raw,value=${{ needs.settings.outputs.docker_version }}_${{ env.arch }} |
41 |
| -
|
42 |
| - - id: buildx-context |
43 |
| - run: | |
44 |
| - docker context create builders |
45 |
| -
|
| 42 | + - run: docker context create builders |
46 | 43 | - uses: docker/setup-buildx-action@v2
|
47 | 44 | with:
|
48 | 45 | endpoint: builders
|
49 |
| - |
50 | 46 | - uses: docker/login-action@v2
|
51 | 47 | with:
|
52 | 48 | username: ${{ secrets.DOCKER_USERNAME }}
|
53 | 49 | password: ${{ secrets.DOCKER_PASSWORD }}
|
54 |
| - |
55 |
| - - id: copy-cache |
56 |
| - name: Copy Buildcache |
57 |
| - run: | |
58 |
| - docker rm -f buildcache |
59 |
| - docker create --name buildcache public.ecr.aws/t3w2s2c9/postgres-buildcache:latest ls |
60 |
| - docker cp buildcache:/ccache/. ./docker/cache |
61 |
| - docker rm -f buildcache |
62 |
| -
|
63 | 50 | - id: build
|
64 | 51 | uses: docker/build-push-action@v3
|
65 | 52 | with:
|
66 | 53 | push: true
|
67 |
| - tags: ${{ steps.meta.outputs.tags }} |
68 |
| - platforms: linux/${{ env.arch }} |
| 54 | + build-args: | |
| 55 | + ${{ needs.settings.outputs.build_args }} |
| 56 | + target: production |
| 57 | + tags: ${{ needs.settings.outputs.image_tag }}_${{ matrix.arch }} |
| 58 | + platforms: linux/${{ matrix.arch }} |
69 | 59 | cache-from: type=gha
|
70 | 60 | cache-to: type=gha,mode=max
|
71 |
| - |
72 |
| - - name: Slack Notification |
73 |
| - if: ${{ failure() }} |
74 |
| - uses: rtCamp/action-slack-notify@v2 |
75 |
| - env: |
76 |
| - SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} |
77 |
| - SLACK_USERNAME: 'gha-failures-notifier' |
78 |
| - SLACK_COLOR: 'danger' |
79 |
| - SLACK_MESSAGE: 'Building Postgres x86 image failed' |
80 |
| - SLACK_FOOTER: '' |
81 |
| - |
82 |
| - docker_arm_release: |
83 |
| - needs: settings |
84 |
| - runs-on: [arm-runner] |
85 |
| - timeout-minutes: 120 |
86 |
| - env: |
87 |
| - arch: arm64 |
88 |
| - outputs: |
89 |
| - image_digest: ${{ steps.build.outputs.digest }} |
90 |
| - steps: |
91 |
| - - uses: actions/checkout@v3 |
92 |
| - |
93 |
| - - id: meta |
94 |
| - uses: docker/metadata-action@v4 |
95 |
| - with: |
96 |
| - images: | |
97 |
| - supabase/postgres |
98 |
| - tags: | |
99 |
| - type=raw,value=${{ needs.settings.outputs.docker_version }}_${{ env.arch }} |
100 |
| -
|
101 |
| - - uses: docker/login-action@v2 |
102 |
| - with: |
103 |
| - username: ${{ secrets.DOCKER_USERNAME }} |
104 |
| - password: ${{ secrets.DOCKER_PASSWORD }} |
105 |
| - |
106 |
| - - id: copy-cache |
107 |
| - name: Copy Buildcache |
108 |
| - run: | |
109 |
| - docker rm -f buildcache |
110 |
| - docker create --name buildcache public.ecr.aws/t3w2s2c9/postgres-buildcache:latest ls |
111 |
| - docker cp buildcache:/ccache/. ./docker/cache/ |
112 |
| - docker rm -f buildcache |
113 |
| -
|
114 |
| - - uses: docker/setup-buildx-action@v2 |
115 |
| - with: |
116 |
| - driver: docker |
117 |
| - driver-opts: | |
118 |
| - image=moby/buildkit:master |
119 |
| - network=host |
120 |
| -
|
121 |
| - - id: build |
122 |
| - uses: docker/build-push-action@v3 |
123 |
| - with: |
124 |
| - context: . |
125 |
| - push: true |
126 |
| - tags: ${{ steps.meta.outputs.tags }} |
127 |
| - platforms: linux/${{ env.arch }} |
128 |
| - no-cache: true |
129 |
| - |
130 | 61 | - name: Slack Notification
|
131 | 62 | if: ${{ failure() }}
|
132 | 63 | uses: rtCamp/action-slack-notify@v2
|
133 | 64 | env:
|
134 | 65 | SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
|
135 |
| - SLACK_USERNAME: 'gha-failures-notifier' |
136 |
| - SLACK_COLOR: 'danger' |
137 |
| - SLACK_MESSAGE: 'Building Postgres arm image failed' |
138 |
| - SLACK_FOOTER: '' |
| 66 | + SLACK_USERNAME: "gha-failures-notifier" |
| 67 | + SLACK_COLOR: "danger" |
| 68 | + SLACK_MESSAGE: "Building Postgres ${{ matrix.arch }} image failed" |
| 69 | + SLACK_FOOTER: "" |
139 | 70 |
|
140 | 71 | merge_manifest:
|
141 |
| - needs: [settings, docker_x86_release, docker_arm_release] |
| 72 | + needs: [settings, build_image] |
142 | 73 | runs-on: ubuntu-latest
|
143 |
| - permissions: |
144 |
| - contents: read |
145 |
| - packages: write |
146 | 74 | steps:
|
147 | 75 | - uses: docker/setup-buildx-action@v2
|
148 |
| - |
149 | 76 | - uses: docker/login-action@v2
|
150 | 77 | with:
|
151 | 78 | username: ${{ secrets.DOCKER_USERNAME }}
|
152 | 79 | password: ${{ secrets.DOCKER_PASSWORD }}
|
153 |
| - |
154 | 80 | - name: Merge multi-arch manifests
|
155 | 81 | run: |
|
156 |
| - docker buildx imagetools create -t supabase/postgres:${{ needs.settings.outputs.docker_version }} \ |
157 |
| - supabase/postgres@${{ needs.docker_x86_release.outputs.image_digest }} \ |
158 |
| - supabase/postgres@${{ needs.docker_arm_release.outputs.image_digest }} |
159 |
| -
|
160 |
| - - name: Login to ECR |
161 |
| - uses: docker/login-action@v2 |
162 |
| - with: |
163 |
| - registry: public.ecr.aws |
164 |
| - username: ${{ secrets.PROD_ACCESS_KEY_ID }} |
165 |
| - password: ${{ secrets.PROD_SECRET_ACCESS_KEY }} |
166 |
| - |
167 |
| - - name: Login to GHCR |
168 |
| - uses: docker/login-action@v2 |
169 |
| - with: |
170 |
| - registry: ghcr.io |
171 |
| - username: ${{ github.actor }} |
172 |
| - password: ${{ secrets.GITHUB_TOKEN }} |
173 |
| - |
174 |
| - - name: Mirror Images |
175 |
| - |
176 |
| - with: |
177 |
| - src: docker.io/supabase/postgres:${{ needs.settings.outputs.docker_version }} |
178 |
| - dst: | |
179 |
| - public.ecr.aws/supabase/postgres:${{ needs.settings.outputs.docker_version }} |
180 |
| - ghcr.io/supabase/postgres:${{ needs.settings.outputs.docker_version }} |
181 |
| -
|
| 82 | + docker buildx imagetools create -t ${{ needs.settings.outputs.image_tag }} \ |
| 83 | + ${{ needs.settings.outputs.image_tag }}_amd64 \ |
| 84 | + ${{ needs.settings.outputs.image_tag }}_arm64 |
182 | 85 | - name: Slack Notification
|
183 | 86 | if: ${{ failure() }}
|
184 | 87 | uses: rtCamp/action-slack-notify@v2
|
185 | 88 | env:
|
186 | 89 | SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
|
187 |
| - SLACK_USERNAME: 'gha-failures-notifier' |
188 |
| - SLACK_COLOR: 'danger' |
189 |
| - SLACK_MESSAGE: 'Building Postgres image failed' |
190 |
| - SLACK_FOOTER: '' |
| 90 | + SLACK_USERNAME: "gha-failures-notifier" |
| 91 | + SLACK_COLOR: "danger" |
| 92 | + SLACK_MESSAGE: "Building Postgres image failed" |
| 93 | + SLACK_FOOTER: "" |
| 94 | + |
| 95 | + publish: |
| 96 | + needs: [settings, merge_manifest] |
| 97 | + # Call workflow explicitly because events from actions cannot trigger more actions |
| 98 | + uses: ./.github/workflows/mirror.yml |
| 99 | + with: |
| 100 | + version: ${{ needs.settings.outputs.docker_version }} |
| 101 | + secrets: inherit |
0 commit comments