Skip to content

Commit 034c102

Browse files
committed
fix: declare different ami name prefix for test and release builds
In order to differentiate AMIs built for testing and those built for release, we need different AMI name. This commit introduces a new input parameter `ami_name_prefix`. For test builds, we set this prefix to include the GitHub run ID, ensuring uniqueness across test builds. For release builds, we use a static prefix "supabase-postgres".
1 parent d67bfb8 commit 034c102

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.github/actions/build-ami/action.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
git_sha:
1515
description: 'Git SHA for this build'
1616
required: true
17+
ami_name_prefix:
18+
description: 'Prefix for the AMI name'
19+
required: false
20+
default: 'supabase-postgres'
1721

1822
outputs:
1923
stage2_ami_id:
@@ -41,8 +45,7 @@ runs:
4145
id: generate-vars
4246
shell: bash
4347
run: |
44-
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres${{ inputs.postgres_version }}"]' ansible/vars.yml)
45-
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"')
48+
PG_VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres${{ inputs.postgres_version }}"]' ansible/vars.yml)
4649
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
4750
echo "" >> common-nix.vars.pkr.hcl
4851
git add -f common-nix.vars.pkr.hcl
@@ -52,6 +55,7 @@ runs:
5255
shell: bash
5356
env:
5457
POSTGRES_MAJOR_VERSION: ${{ inputs.postgres_version }}
58+
POSTGRES_VERSION: ${{ steps.generate-vars.outputs.version }}
5559
AWS_MAX_ATTEMPTS: 10
5660
AWS_RETRY_MODE: adaptive
5761
AWS_REGION: ${{ inputs.region }}
@@ -63,14 +67,14 @@ runs:
6367
-var "region=${{ inputs.region }}" \
6468
-var 'ami_regions=${{ inputs.ami_regions }}' \
6569
-var-file="development-arm.vars.pkr.hcl" \
66-
-var-file="common-nix.vars.pkr.hcl" \
6770
amazon-arm64-nix.pkr.hcl
6871
6972
- name: Build AMI stage 2
7073
id: build-stage2
7174
shell: bash
7275
env:
7376
POSTGRES_MAJOR_VERSION: ${{ inputs.postgres_version }}
77+
POSTGRES_VERSION: ${{ steps.generate-vars.outputs.version }}
7478
PACKER_EXECUTION_ID: ${{ env.EXECUTION_ID }}
7579
AWS_MAX_ATTEMPTS: 10
7680
AWS_RETRY_MODE: adaptive
@@ -82,7 +86,7 @@ runs:
8286
-var "postgres_major_version=${{ inputs.postgres_version }}" \
8387
-var-file="development-arm.vars.pkr.hcl" \
8488
-var-file="common-nix.vars.pkr.hcl" \
85-
-var "postgres-version=${{ env.EXECUTION_ID }}" \
89+
-var "ami_name=${{ inputs.ami_name_prefix }}" \
8690
-var 'ami_regions=${{ inputs.ami_regions }}' \
8791
-var "force-deregister=true" \
8892
-var "git_sha=${{ inputs.git_sha }}" \

.github/workflows/ami-release-nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
-e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \
132132
-e "postgres_major_version=${{ matrix.postgres_version }}" \
133133
manifest-playbook.yml
134-
134+
135135
- name: Upload nix flake revision to s3 prod
136136
run: |
137137
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz

.github/workflows/testinfra-ami-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
region: ap-southeast-1
9898
ami_regions: '["ap-southeast-1"]'
9999
git_sha: ${{ github.sha }}
100+
ami_name_prefix: "supabase-postgres-{{ github.run_id }}"
100101

101102
- name: Run tests
102103
timeout-minutes: 10

nix/packages/build-ami.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ writeShellApplication {
5454
shift || true # Remove first arg, ignore error if no args
5555
5656
REGION="''${AWS_REGION:-ap-southeast-1}"
57-
POSTGRES_VERSION="''${POSTGRES_MAJOR_VERSION:-15}"
5857
PACKER_SOURCES="${packerSources}"
5958
INPUT_HASH=$(basename "$PACKER_SOURCES" | cut -d- -f1)
6059

0 commit comments

Comments
 (0)