ceeac5c02f
Bumps the github-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [DeterminateSystems/nix-installer-action](https://github.com/determinatesystems/nix-installer-action) and [DeterminateSystems/magic-nix-cache-action](https://github.com/determinatesystems/magic-nix-cache-action). Updates `actions/checkout` from 4 to 7 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v7) Updates `DeterminateSystems/nix-installer-action` from 16 to 22 - [Release notes](https://github.com/determinatesystems/nix-installer-action/releases) - [Commits](https://github.com/determinatesystems/nix-installer-action/compare/v16...v22) Updates `DeterminateSystems/magic-nix-cache-action` from 8 to 14 - [Release notes](https://github.com/determinatesystems/magic-nix-cache-action/releases) - [Commits](https://github.com/determinatesystems/magic-nix-cache-action/compare/v8...v14) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: DeterminateSystems/magic-nix-cache-action dependency-version: '14' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: DeterminateSystems/nix-installer-action dependency-version: '22' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
85 lines
2.5 KiB
YAML
85 lines
2.5 KiB
YAML
name: Nix Build & Deploy — All Services
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'apps/**'
|
|
- 'infra/**'
|
|
- 'flake.nix'
|
|
- 'flake.lock'
|
|
- '.github/workflows/nix-build.yml'
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: nix-deploy
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
VPS_HOST: ${{ secrets.VPS_HOST }}
|
|
VPS_USER: ${{ secrets.VPS_USER }}
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
service: [hub, scraper, tools-gateway, tools-workers, tools-frontend, llm-api]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
|
|
- name: Install Nix
|
|
uses: DeterminateSystems/nix-installer-action@v22
|
|
with:
|
|
determinate: false
|
|
extra-conf: |
|
|
sandbox = false
|
|
accept-flake-config = true
|
|
|
|
- name: Cache Nix
|
|
uses: DeterminateSystems/magic-nix-cache-action@v14
|
|
|
|
- name: Build ${{ matrix.service }}
|
|
id: build
|
|
run: |
|
|
nix build .#${{ matrix.service }} --impure --option sandbox false --print-build-logs
|
|
STORE_PATH=$(readlink result)
|
|
echo "store-path=$STORE_PATH" >> "$GITHUB_OUTPUT"
|
|
echo "✅ ${{ matrix.service }}: $STORE_PATH"
|
|
|
|
- name: Setup SSH key
|
|
if: github.ref == 'refs/heads/main'
|
|
env:
|
|
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "$SSH_KEY" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
sed -i 's/\r$//' ~/.ssh/id_ed25519
|
|
ssh-keygen -y -f ~/.ssh/id_ed25519 >/dev/null 2>&1 || { echo "SSH key invalid"; exit 1; }
|
|
ssh-keyscan -H "$VPS_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: Deploy ${{ matrix.service }} to VPS
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
STORE_PATH="${{ steps.build.outputs.store-path }}"
|
|
echo "=== Copying ${{ matrix.service }}: $STORE_PATH ==="
|
|
nix copy --to "ssh://$VPS_USER@$VPS_HOST" "$STORE_PATH"
|
|
|
|
echo "=== Updating profile ==="
|
|
ssh "$VPS_USER@$VPS_HOST" "sudo /nix/var/nix/profiles/default/bin/nix-env --profile /nix/var/nix/profiles/${{ matrix.service }} --set '$STORE_PATH'"
|
|
|
|
echo "=== Restarting service ==="
|
|
ssh "$VPS_USER@$VPS_HOST" "sudo systemctl restart ${{ matrix.service }}" || echo " ⚠️ restart failed (may not be enabled yet)"
|
|
|
|
echo "✅ ${{ matrix.service }} deployed"
|