ci: Custom GitHub Runners for Nix Builds #3550
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nix CI | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - release/* | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| # required by dependent workflows | |
| contents: write | |
| packages: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| nix-matrix: | |
| runs-on: | |
| group: self-hosted-runners-nix | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: set-matrix | |
| name: Generate Nix Matrix | |
| run: | | |
| set -Eeu | |
| # fast eval | |
| nix-eval-jobs -- --flake '.#githubActions.matrix' | |
| # capture the output | |
| matrix="$(nix eval --json '.#githubActions.matrix')" | |
| echo "matrix=$matrix" >> "$GITHUB_OUTPUT" | |
| build-run-image: | |
| name: ${{ matrix.name }} (${{ matrix.system }}) | |
| needs: nix-matrix | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} | |
| timeout-minutes: 180 | |
| steps: | |
| - name: Checkout Repo | |
| uses: supabase/postgres/.github/actions/shared-checkout@HEAD | |
| - name: aws-oidc | |
| uses: aws-actions/[email protected] | |
| with: | |
| aws-region: us-east-2 | |
| role-to-assume: arn:aws:iam::279559813984:role/supabase-github-oidc-role # Shared Services | |
| role-session-name: gha-oidc-${{ github.run_id }} | |
| - name: aws-creds | |
| uses: aws-actions/[email protected] | |
| with: | |
| disable-retry: true | |
| aws-region: us-east-2 | |
| role-to-assume: arn:aws:iam::436098097459:role/nix-artifacts-deploy-role # supabase-dev | |
| role-session-name: gha-oidc-${{ github.run_id }} | |
| role-chaining: true | |
| role-skip-session-tagging: true | |
| role-duration-seconds: 18000 # 5 hours | |
| - name: Write creds files | |
| run: | | |
| umask 006 | |
| cat > /etc/nix/aws/nix-aws-credentials <<EOF | |
| [ci-uploader] | |
| aws_access_key_id = ${AWS_ACCESS_KEY_ID} | |
| aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY} | |
| aws_session_token = ${AWS_SESSION_TOKEN} | |
| EOF | |
| - run: nix build -L '.#${{ matrix.attr }}' | |
| run-tests: | |
| needs: build-run-image | |
| if: ${{ success() }} | |
| uses: ./.github/workflows/test.yml |