8
8
workflow_dispatch :
9
9
10
10
jobs :
11
+ prepare :
12
+ runs-on : ubuntu-latest
13
+ outputs :
14
+ postgres_versions : ${{ steps.set-versions.outputs.postgres_versions }}
15
+ steps :
16
+ - name : Checkout Repo
17
+ uses : actions/checkout@v4
18
+
19
+ - uses : DeterminateSystems/nix-installer-action@main
20
+
21
+ - name : Set PostgreSQL versions
22
+ id : set-versions
23
+ run : |
24
+ VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
25
+ echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
26
+
11
27
build :
28
+ needs : prepare
12
29
strategy :
13
30
matrix :
31
+ postgres_version : ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
14
32
include :
15
33
- runner : [self-hosted, X64]
16
34
arch : amd64
@@ -23,14 +41,31 @@ jobs:
23
41
POSTGRES_PASSWORD : password
24
42
steps :
25
43
- uses : actions/checkout@v3
44
+
45
+ - uses : DeterminateSystems/nix-installer-action@main
46
+
47
+ - name : Set PostgreSQL version environment variable
48
+ run : echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
49
+
50
+ - name : Generate common-nix.vars.pkr.hcl
51
+ run : |
52
+ PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
53
+ PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
54
+ echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
55
+ # Ensure there's a newline at the end of the file
56
+ echo "" >> common-nix.vars.pkr.hcl
57
+
26
58
- id : settings
27
59
# Remove spaces and quotes to get the raw version string
28
60
run : sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT
29
61
30
- - id : args
31
- uses : mikefarah/yq@master
32
- with :
33
- cmd : yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'
62
+ - name : Generate args
63
+ id : args
64
+ run : |
65
+ ARGS=$(nix run nixpkgs#yq -- 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' ansible/vars.yml)
66
+ echo "result<<EOF" >> $GITHUB_OUTPUT
67
+ echo "$ARGS" >> $GITHUB_OUTPUT
68
+ echo "EOF" >> $GITHUB_OUTPUT
34
69
35
70
- run : docker context create builders
36
71
- uses : docker/setup-buildx-action@v3
0 commit comments