88 GIT_REF :
99 type : string
1010 required : false
11+ secrets :
12+ AWS_ACCOUNT_ID :
13+ required : true
14+ NIX_CACHE_PUB_KEY :
15+ required : true
16+ NIX_CACHE_PRIV_KEY :
17+ required : true
1118
1219jobs :
1320 tests :
14- # These permissions are needed to interact with GitHub's OIDC Token endpoint.
21+ runs-on : blacksmith-2vcpu-ubuntu-2404-arm
22+ timeout-minutes : 30
23+
1524 permissions :
1625 id-token : write
1726 contents : write
1827
19-
20- runs-on : ubuntu-22.04
21- timeout-minutes : 180
22-
2328 steps :
2429 - name : " Check out repository"
2530 uses : actions/checkout@v4
2631 with :
2732 fetch-depth : 0
2833 ref : ${{ inputs.GIT_REF }}
34+ actions : read
35+
36+ - name : Configure aws
37+ uses : aws-actions/configure-aws-credentials@v4
38+ with :
39+ role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
40+ aws-region : eu-central-1
41+
42+ - name : Login to Amazon ECR
43+ id : login-ecr
44+ uses : aws-actions/amazon-ecr-login@v2
45+ with :
46+ mask-password : ' true'
2947
3048 - uses : cachix/install-nix-action@v31
3149 with :
@@ -35,39 +53,43 @@ jobs:
3553 experimental-features = nix-command flakes
3654 sandbox = false
3755 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
38- substituters = https://cache.nixos.org/?priority=40
39- trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
40-
41- - uses : DeterminateSystems/magic-nix-cache-action@v9
42- with :
43- diagnostic-endpoint : " "
44- use-flakehub : false
56+ substituters = https://cache.nixos.org/?priority=40 s3://nhost-nix-cache?region=eu-central-1&priority=50
57+ trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{ secrets.NIX_CACHE_PUB_KEY }}
4558
4659 - name : " Verify if we need to build"
4760 id : verify-build
4861 run : |
49- export drvPath=$(make check-dry-run)
50- echo "drvPath - $drvPath"
51- nix store verify --no-trust --store http://127.0.0.1:37515 $drvPath \
52- && export BUILD_NEEDED=no \
53- || export BUILD_NEEDED=yes
62+ export drvPathGo=$(make check-dry-run-go)
63+ export drvPathNode=$(make check-dry-run-node)
64+
65+ nix store verify --no-trust --store s3://nhost-nix-cache\?region=eu-central-1 $drvPathGo \
66+ && export GO_BUILD_NEEDED=no \
67+ || export GO_BUILD_NEEDED=yes
68+
69+ nix store verify --no-trust --store s3://nhost-nix-cache\?region=eu-central-1 $drvPathNode \
70+ && export NODE_BUILD_NEEDED=no \
71+ || export NODE_BUILD_NEEDED=yes
72+
73+ # Set BUILD_NEEDED to yes if either Go or Node build is needed
74+ if [ "$GO_BUILD_NEEDED" = "yes" ] || [ "$NODE_BUILD_NEEDED" = "yes" ]; then
75+ export BUILD_NEEDED=yes
76+ else
77+ export BUILD_NEEDED=no
78+ fi
5479
5580 echo BUILD_NEEDED=$BUILD_NEEDED >> $GITHUB_OUTPUT
56- echo DERIVATION_PATH=$drvPath >> $GITHUB_OUTPUT
5781
5882 - name : " Start containters for integration tests"
5983 run : |
60- make build-docker-image
61- nix develop -c make dev-env-up
84+ nix develop .\#${{ inputs.NAME }} -c make dev-env-up
6285 if : ${{ steps.verify-build.outputs.BUILD_NEEDED == 'yes' }}
6386
6487 - name : " Run checks"
6588 run : make check
6689 if : ${{ steps.verify-build.outputs.BUILD_NEEDED == 'yes' }}
6790
68- - name : " Cache checks "
91+ - name : " Cache build "
6992 run : |
70- # DEPENDENCIES=($(nix-store --query --requisites --include-outputs ${{ steps.verify-build.outputs.DERIVATION_PATH }}))
71- # nix copy --to http://127.0.0.1:37515 "${DEPENDENCIES[@]}" || exit 0
72- nix copy --to http://127.0.0.1:37515 ${{ steps.verify-build.outputs.DERIVATION_PATH }}|| exit 0
73- if : ${{ steps.verify-build.outputs.BUILD_NEEDED == 'yes' }}
93+ nix store sign --key-file <(echo "${{ secrets.NIX_CACHE_PRIV_KEY }}") --all
94+ find /nix/store -maxdepth 1 -name "*-*" -type d -exec nix copy --to s3://nhost-nix-cache\?region=eu-central-1 {} \;
95+ if : always()
0 commit comments