summaryrefslogtreecommitdiff
path: root/.github/workflows/deploy.yaml
blob: 113a847edc82cfdd54fe86fcd4b63e6e85bbf025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Deploy systems

on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  ci:
    name: CI
    uses: ./.github/workflows/ci.yaml
    secrets: inherit

  deploy:
    name: Deploy all
    needs: ci
    runs-on: ubuntu-latest

    concurrency:
      group: deploy
      cancel-in-progress: true

    steps:
      - uses: actions/checkout@v4

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@v9

      - name: Setup local Nix cache
        uses: DeterminateSystems/magic-nix-cache-action@v2

      - name: Connect to Tailscale
        uses: tailscale/github-action@v2
        with:
          oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
          oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
          tags: tag:gha

      - name: Add pubkeys to known_hosts
        run: |
          set -eux

          [ ! -d ~/.ssh ] && mkdir -p ~/.ssh
          pubkeys=(
            "atlas ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7YiSYYx/+zmVOPSCERHzSsMeUQtA+Vt1W0sLUw4YhK"
          )

          for key in "${pubkeys[@]}"; do echo "$key" >> ~/.ssh/known_hosts; done

      - name: Run deploy
        run: |
          nix develop --accept-flake-config \
            --command bash \
            -c "just deploy-all"