Different Nix configurations for qs and prod

This commit is contained in:
thiloho
2024-09-15 14:23:54 +02:00
parent 756040e5ea
commit cc3687aaca
6 changed files with 57 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
name: Deploy app to server
name: Deploy to server
on:
workflow_run:
@@ -7,12 +7,13 @@ on:
branches: [ devel, main ]
env:
SERVER_USER: root
SERVER_IP: 128.140.75.240
QS_SERVER_IP: 128.140.75.240
PROD_SERVER_IP: 128.140.75.240
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.event == 'push' }}
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.event != 'pull_request' }}
steps:
- uses: actions/checkout@v4
@@ -24,14 +25,14 @@ jobs:
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEMO_SERVER_SSH_KEY }}
known_hosts: ${{ secrets.DEMO_SERVER_KNOWN_HOSTS }}
key: ${{ github.ref_name == 'devel' && secrets.QS_SSH_KEY || secrets.PROD_SSH_KEY }}
known_hosts: ${{ github.ref_name == 'devel' && secrets.QS_KNOWN_HOSTS || secrets.PROD_KNOWN_HOSTS }}
- name: Deploy to demo server
run: |
nix run nixpkgs#nixos-rebuild -- switch \
--flake .#demo-server \
--flake .#$[ github.ref_name == 'devel' && 'qs' || 'prod' ] \
--fast \
--build-host ${{ env.SERVER_USER }}@${{ env.SERVER_IP }} \
--target-host ${{ env.SERVER_USER }}@${{ env.SERVER_IP }} \
--build-host ${{ env.SERVER_USER }}@$[ github.ref_name == 'devel' && env.QS_SERVER_IP || env.PROD_SERVER_IP ] \
--target-host ${{ env.SERVER_USER }}@$[ github.ref_name == 'devel' && env.QS_SERVER_IP || env.PROD_SERVER_IP ] \
--use-remote-sudo