Skip to content

Commit 2a63f6f

Browse files
committed
merge develop
2 parents d31d94b + 956dfd8 commit 2a63f6f

File tree

108 files changed

+1981
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1981
-622
lines changed

.github/workflows/ami-release.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,23 @@ jobs:
1818

1919
- name: Build AMI
2020
run: |
21-
GIT_SHA=$(git rev-parse HEAD)
22-
packer build -var "git-head-version=${GIT_SHA}" -var-file="development-arm.vars.pkr.hcl" -var-file="common.vars.pkr.hcl" amazon-arm64.pkr.hcl
21+
GIT_SHA=${{github.sha}}
22+
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common.vars.pkr.hcl" amazon-arm64.pkr.hcl
2323
24-
- name: Slack Notification
24+
- name: Grab release version
25+
id: process_release_version
26+
run: |
27+
VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common.vars.pkr.hcl)
28+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29+
30+
- name: Create release
31+
uses: softprops/action-gh-release@v1
32+
with:
33+
name: ${{ steps.process_release_version.outputs.version }}
34+
tag_name: ${{ steps.process_release_version.outputs.version }}
35+
target_commitish: ${{github.sha}}
36+
37+
- name: Slack Notification on Failure
2538
if: ${{ failure() }}
2639
uses: rtCamp/action-slack-notify@v2
2740
env:
@@ -30,3 +43,8 @@ jobs:
3043
SLACK_COLOR: 'danger'
3144
SLACK_MESSAGE: 'Building Postgres AMI failed'
3245
SLACK_FOOTER: ''
46+
47+
- name: Cleanup resources on build cancellation
48+
if: ${{ cancelled() }}
49+
run: |
50+
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -I {} aws ec2 terminate-instances --instance-ids {}

.github/workflows/build-ccache.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Update ccache
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths:
8+
- ".github/workflows/build-ccache.yml"
9+
- "ansible/vars.yml"
10+
- "Dockerfile"
11+
workflow_dispatch:
12+
13+
env:
14+
image_tag: public.ecr.aws/supabase/postgres:ccache
15+
permissions:
16+
contents: read
17+
packages: write
18+
id-token: write
19+
20+
jobs:
21+
settings:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
build_args: ${{ steps.args.outputs.result }}
25+
steps:
26+
- uses: actions/checkout@v3
27+
- id: args
28+
uses: mikefarah/yq@master
29+
with:
30+
cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'
31+
32+
build_image:
33+
needs: settings
34+
strategy:
35+
matrix:
36+
include:
37+
- runner: [self-hosted, X64]
38+
arch: amd64
39+
- runner: arm-runner
40+
arch: arm64
41+
runs-on: ${{ matrix.runner }}
42+
timeout-minutes: 180
43+
outputs:
44+
image_digest: ${{ steps.build.outputs.digest }}
45+
steps:
46+
- run: docker context create builders
47+
- uses: docker/setup-buildx-action@v2
48+
with:
49+
endpoint: builders
50+
- name: Configure AWS credentials - prod
51+
uses: aws-actions/configure-aws-credentials@v1
52+
with:
53+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
54+
aws-region: "us-east-1"
55+
- uses: docker/login-action@v2
56+
with:
57+
registry: public.ecr.aws
58+
- id: build
59+
uses: docker/build-push-action@v3
60+
with:
61+
push: true
62+
target: buildcache
63+
build-args: |
64+
CACHE_EPOCH=${{ github.event.repository.updated_at }}
65+
${{ needs.settings.outputs.build_args }}
66+
tags: ${{ env.image_tag }}_${{ matrix.arch }}
67+
platforms: linux/${{ matrix.arch }}
68+
69+
merge_manifest:
70+
needs: build_image
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: docker/setup-buildx-action@v2
74+
- name: Configure AWS credentials - prod
75+
uses: aws-actions/configure-aws-credentials@v1
76+
with:
77+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
78+
aws-region: "us-east-1"
79+
- uses: docker/login-action@v2
80+
with:
81+
registry: public.ecr.aws
82+
- name: Merge multi-arch manifests
83+
run: |
84+
docker buildx imagetools create -t ${{ env.image_tag }} \
85+
${{ env.image_tag }}_amd64 \
86+
${{ env.image_tag }}_arm64
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Check shell scripts
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Run ShellCheck
16+
uses: ludeeus/action-shellcheck@master
17+
env:
18+
SHELLCHECK_OPTS: -e SC2001 -e SC2002 -e SC2143
19+
with:
20+
scandir: './ansible/files/admin_api_scripts'

.github/workflows/dockerhub-release.yml

Lines changed: 45 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -5,186 +5,97 @@ on:
55
branches:
66
- develop
77
paths:
8-
- '.github/workflows/dockerhub-release.yml'
9-
- 'common.vars*'
8+
- ".github/workflows/dockerhub-release.yml"
9+
- "common.vars*"
1010

1111
jobs:
1212
settings:
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-latest
1414
outputs:
1515
docker_version: ${{ steps.settings.outputs.postgres-version }}
16+
image_tag: supabase/postgres:${{ steps.settings.outputs.postgres-version }}
17+
build_args: ${{ steps.args.outputs.result }}
1618
steps:
1719
- uses: actions/checkout@v3
18-
1920
- id: settings
2021
# Remove spaces and quotes to get the raw version string
2122
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'
2227

23-
docker_x86_release:
28+
build_image:
2429
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
2939
outputs:
3040
image_digest: ${{ steps.build.outputs.digest }}
3141
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
4643
- uses: docker/setup-buildx-action@v2
4744
with:
4845
endpoint: builders
49-
5046
- uses: docker/login-action@v2
5147
with:
5248
username: ${{ secrets.DOCKER_USERNAME }}
5349
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-
6350
- id: build
6451
uses: docker/build-push-action@v3
6552
with:
6653
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 }}
6959
cache-from: type=gha
7060
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-
13061
- name: Slack Notification
13162
if: ${{ failure() }}
13263
uses: rtCamp/action-slack-notify@v2
13364
env:
13465
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: ""
13970

14071
merge_manifest:
141-
needs: [settings, docker_x86_release, docker_arm_release]
72+
needs: [settings, build_image]
14273
runs-on: ubuntu-latest
143-
permissions:
144-
contents: read
145-
packages: write
14674
steps:
14775
- uses: docker/setup-buildx-action@v2
148-
14976
- uses: docker/login-action@v2
15077
with:
15178
username: ${{ secrets.DOCKER_USERNAME }}
15279
password: ${{ secrets.DOCKER_PASSWORD }}
153-
15480
- name: Merge multi-arch manifests
15581
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-
uses: akhilerm/[email protected]
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
18285
- name: Slack Notification
18386
if: ${{ failure() }}
18487
uses: rtCamp/action-slack-notify@v2
18588
env:
18689
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

Comments
 (0)