55 workflow_dispatch :
66
77jobs :
8+ prepare :
9+ runs-on : ubuntu-latest
10+ outputs :
11+ postgres_versions : ${{ steps.set-versions.outputs.postgres_versions }}
12+ steps :
13+ - name : Checkout Repo
14+ uses : actions/checkout@v4
15+
16+ - uses : DeterminateSystems/nix-installer-action@main
17+
18+ - name : Set PostgreSQL versions
19+ id : set-versions
20+ run : |
21+ VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
22+ echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
23+
824 test-ami-nix :
25+ needs : prepare
926 strategy :
1027 fail-fast : false
1128 matrix :
29+ postgres_version : ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
1230 include :
1331 - runner : arm-runner
1432 arch : arm64
1533 ubuntu_release : focal
1634 ubuntu_version : 20.04
1735 mcpu : neoverse-n1
18- runs-on : ${{ matrix.runner }}
36+ runs-on : ${{ matrix.runner }}
1937 timeout-minutes : 150
2038 permissions :
2139 contents : write
@@ -40,18 +58,29 @@ jobs:
4058 - name : Generate random string
4159 id : random
4260 run : echo "random_string=$(openssl rand -hex 8)" >> $GITHUB_OUTPUT
61+
62+ - name : Set PostgreSQL version environment variable
63+ run : echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
64+
65+ - name : Generate common-nix.vars.pkr.hcl
66+ run : |
67+ PG_VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
68+ PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
69+ echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
70+ # Ensure there's a newline at the end of the file
71+ echo "" >> common-nix.vars.pkr.hcl
4372
4473 - name : Build AMI stage 1
4574 run : |
4675 packer init amazon-arm64-nix.pkr.hcl
4776 GIT_SHA=${{github.sha}}
48- 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-nix.vars.pkr.hcl" -var "ansible_arguments=" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" amazon-arm64-nix.pkr.hcl
77+ 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-nix.vars.pkr.hcl" -var "ansible_arguments=" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl
4978
5079 - name : Build AMI stage 2
5180 run : |
5281 packer init stage2-nix-psql.pkr.hcl
5382 GIT_SHA=${{github.sha}}
54- 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-nix.vars.pkr.hcl" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" -var "git_sha=${GITHUB_SHA}" stage2-nix-psql.pkr.hcl
83+ packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -var -file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" -var "git_sha=${GITHUB_SHA}" stage2-nix-psql.pkr.hcl
5584
5685 - name : Run tests
5786 timeout-minutes : 10
0 commit comments