Skip to content

Commit bd3a1e2

Browse files
committed
feat: Deploy to staging by default on merge
Deploying to production now requires a merge on the `production` branch.
1 parent 05aedad commit bd3a1e2

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.github/workflows/deployments.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ on:
77
types:
88
- completed
99
push:
10-
branches: main
10+
branches: [main, production]
1111
jobs:
12-
deploy-to-staging:
12+
deploy-environment:
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
include:
17+
- environment: staging
18+
host: staging-tracker.security.nixos.org
19+
branch: main
20+
- environment: production
21+
host: tracker.security.nixos.org
22+
branch: production
1423
steps:
1524
- uses: actions/checkout@v4
1625
- uses: cachix/install-nix-action@v29
@@ -19,4 +28,7 @@ jobs:
1928
ssh-private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
2029
- name: Trust staging server public SSH host keys
2130
run: cat ./infra/host_keys >> ~/.ssh/known_hosts
22-
- run: nix-shell default.nix -A ci --run deploy
31+
- name: Deploy to ${{ matrix.environment }}
32+
# Only deploy production when on production branch
33+
if: github.ref == 'refs/heads/${{ matrix.branch }}'
34+
run: nix-shell default.nix -A ci --run "deploy switch ${{ matrix.host }}"

infra/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ For more instructions on how to use OpenTofu refer to the [upstream documentatio
2323
Since Hetzner Cloud doesn't support NixOS out of the box, the VM was initially spawned as a Debian host and then it was converted to NixOS as per the [provisioning NixOS via SSH tutorial](https://nix.dev/tutorials/nixos/provisioning-remote-machines).
2424
If in the future we need to create more VMs and do it in a declarative way, we can use [nixos-anywhere](https://github.com/nix-community/nixos-anywhere).
2525

26+
## Deploying the Security Tracker
27+
28+
Deployments happen automatically via GitHub Actions. Whenever something is merged on a the `main` branch, a GitHub Action runs that updates the staging deployment of the tracker (staging-tracker.security.nixos.org).
29+
Similarly, merges on the `production` branch get automatically applied to tracker.security.nixos.org.
30+
2631
## Secrets
2732

2833
Secrets are managed using [Agenix](https://github.com/ryantm/agenix).

0 commit comments

Comments
 (0)