From 8767e61552fcce8a0e5d765652ff8b9ccdfe7caf Mon Sep 17 00:00:00 2001 From: xinyangli Date: Fri, 20 Dec 2024 18:03:12 +0800 Subject: [PATCH] ci: eval deploy --- .github/workflows/eval.yaml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/eval.yaml diff --git a/.github/workflows/eval.yaml b/.github/workflows/eval.yaml new file mode 100644 index 0000000..9397e40 --- /dev/null +++ b/.github/workflows/eval.yaml @@ -0,0 +1,54 @@ +name: Deploy NixOS Configurations + +on: + push: + branches: + - deploy + workflow_dispatch: + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: deploy + + - name: Install Nix + uses: cachix/install-nix-action@v25 + + - name: Configure Git + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "actions@github.com" + + - name: Process Configurations + run: | + # Create deploy-comin-eval branch if it doesn't exist + if ! git show-ref --verify --quiet refs/remotes/origin/deploy-comin-eval; then + git checkout -b deploy-comin-eval + else + git checkout deploy-comin-eval || git checkout -b deploy-comin-eval origin/deploy-comin-eval + fi + + # Create eval directory if it doesn't exist + mkdir -p eval + + # Get all hosts and create their json files + hosts=$(nix flake show --json | jq -r '.nixosConfigurations | keys[]') + + for host in $hosts; do + # Generate json file for the host in eval directory + nix show-derivation -L ".#nixosConfigurations.$host.config.system.build.toplevel" > "eval/$host.json" + done + + # Add all json files and commit + git add eval/ + git commit -m "Update deployment configurations for all hosts" + + # Push directly to deploy-comin-eval + git push origin deploy-comin-eval