From f1813b4a47e87417d3d32d9078ed0d9c79eec3dd Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 23 May 2024 13:27:08 -0500 Subject: [PATCH] abstract --- .github/workflows/build.yml | 51 ++++++++++++++++++++------------ .github/workflows/on-demand.yml | 52 --------------------------------- .github/workflows/push.yml | 23 +++++++++++++++ 3 files changed, 56 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/on-demand.yml create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f4b350..1735478 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,30 +1,39 @@ -name: Build NixOS +name: Build NixOS (on demand) on: - push: - branches: - - main - pull_request: - branches: - - main + workflow_dispatch: + inputs: + host: + description: 'host name to build' + required: true + default: 'othalan' + type: string + lockFile: + description: 'flake.lock file' + type: string + + workflow_call: + inputs: + host: + description: 'host name to build' + required: true + default: 'othalan' + type: string + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.host }} + cancel-in-progress: true jobs: build: runs-on: ubuntu-latest - strategy: - max-parallel: 1 - matrix: - host: - - othalan - # - mannaz - # - algiz steps: # free up some space - run: sudo rm -rf /opt& - - uses: actions/checkout@v4 - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main + + - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@v2 - uses: cachix/cachix-action@v14 @@ -32,6 +41,12 @@ jobs: name: daylin authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: write lock file + if: "${{ inputs.lockFile != '' }}" + run: | + echo '${{ inputs.lockFile }}' > flake.lock + git diff + - name: Build run: | - nix run . --accept-flake-config -- cache --host "${{ matrix.host }}" --flake . + nix run . --accept-flake-config -- cache --host "${{ inputs.host }}" --flake . diff --git a/.github/workflows/on-demand.yml b/.github/workflows/on-demand.yml deleted file mode 100644 index 1735478..0000000 --- a/.github/workflows/on-demand.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build NixOS (on demand) - -on: - workflow_dispatch: - inputs: - host: - description: 'host name to build' - required: true - default: 'othalan' - type: string - lockFile: - description: 'flake.lock file' - type: string - - workflow_call: - inputs: - host: - description: 'host name to build' - required: true - default: 'othalan' - type: string - - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.host }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - steps: - # free up some space - - run: sudo rm -rf /opt& - - uses: actions/checkout@v4 - - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@v2 - - - uses: cachix/cachix-action@v14 - with: - name: daylin - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - name: write lock file - if: "${{ inputs.lockFile != '' }}" - run: | - echo '${{ inputs.lockFile }}' > flake.lock - git diff - - - name: Build - run: | - nix run . --accept-flake-config -- cache --host "${{ inputs.host }}" --flake . diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..88c7d9c --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,23 @@ +name: Build NixOS + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + strategy: + max-parallel: 1 + matrix: + host: + - othalan + # - mannaz + # - algiz + uses: ./.github/workflows/build.yml + with: + host: "${{ matrix.host }}" + secrets: inherit