Build nix packages #1251
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build nix packages | |
on: | |
workflow_dispatch: | |
inputs: | |
host: | |
description: "which host profile to build" | |
type: string | |
required: true | |
default: "cicd-x86_64-linux" | |
nix-system: | |
description: "which system this host uses" | |
type: string | |
required: true | |
default: "x86_64-linux" | |
deploy-to-node: | |
description: "deploy to nodes" | |
type: boolean | |
default: false | |
required: false | |
free-disk-space: | |
description: "free disk space" | |
type: boolean | |
default: true | |
required: false | |
ignore-errors: | |
description: "ignore errors" | |
type: boolean | |
default: false | |
required: false | |
update-nix-inputs: | |
description: "update nix inputs" | |
type: boolean | |
default: false | |
required: false | |
pull_request: | |
branches: | |
- master | |
- main | |
- actions | |
- ci | |
- "releases/*" | |
paths: | |
- "*.nix" | |
- "**/*.nix" | |
- "nix/**" | |
- "flake.lock" | |
push: | |
branches: | |
- master | |
- main | |
- actions | |
- ci | |
- "releases/*" | |
paths: | |
- ".github/workflows/nix*.yml" | |
- "*.nix" | |
- "**/*.nix" | |
- "nix/**" | |
- "flake.lock" | |
schedule: | |
- cron: "0 16 * * 1" | |
- cron: "0 16 * * 5" | |
jobs: | |
build-packages: | |
if: github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' | |
uses: ./.github/workflows/nix-large-packages.yml | |
build-nixos: | |
if: github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' | |
strategy: | |
matrix: | |
include: | |
- host: "cicd-x86_64-linux" | |
nix-system: "x86_64-linux" | |
- host: "cicd-aarch64-linux" | |
nix-system: "aarch64-linux" | |
ignore-errors: true | |
uses: ./.github/workflows/nixos.yml | |
with: | |
host: "${{ matrix.host || 'cicd-x86_64-linux' }}" | |
nix-system: "${{ matrix.nix-system || 'x86_64-linux' }}" | |
deploy-to-node: "${{ matrix.deploy-to-node || false }}" | |
free-disk-space: "${{ matrix.free-disk-space || false }}" | |
ignore-errors: "${{ matrix.ignore-errors || false }}" | |
update-nix-inputs: "${{ matrix.update-nix-inputs || false }}" | |
secrets: inherit | |
build-nixos-when-needed: | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
uses: ./.github/workflows/nixos.yml | |
with: | |
host: "${{ inputs.host || 'cicd-x86_64-linux' }}" | |
nix-system: "${{ inputs.nix-system || 'x86_64-linux' }}" | |
deploy-to-node: "${{ inputs.deploy-to-node || false }}" | |
free-disk-space: "${{ inputs.free-disk-space || github.event_name == 'schedule' }}" | |
ignore-errors: "${{ inputs.ignore-errors || false }}" | |
update-nix-inputs: "${{ inputs.update-nix-inputs || github.event_name == 'schedule' }}" | |
secrets: inherit | |
build-packages-when-needed: | |
needs: | |
- build-nixos-when-needed | |
if: needs.build-nixos-when-needed.outputs.shouldPushUpdates == 'yes' | |
uses: ./.github/workflows/nix-large-packages.yml | |
with: | |
branch: ${{ needs.build-nixos-when-needed.outputs.branch }} | |
create-pull-request-when-needed: | |
runs-on: ubuntu-latest | |
needs: | |
- build-nixos-when-needed | |
- build-packages-when-needed | |
if: needs.build-nixos-when-needed.outputs.shouldPushUpdates == 'yes' | |
steps: | |
- name: create or update pull request | |
run: | | |
repo="${{ github.repository }}" | |
base="${{ github.event.repository.default_branch }}" | |
head="${{ needs.build-nixos-when-needed.outputs.branch }}" | |
link="[github action run log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
if id="$(gh pr -R "$repo" list -B "$base" -H "$head" --json number --limit 1 --jq '.[].number')" && [[ -n "$id" ]]; then | |
gh pr -R "$repo" comment "$id" --body "PR updated. See $link." | |
else | |
gh pr -R "$repo" create -B "$base" -H "$head" --title 'update nix flake inputs' --body "Created by Github action. See $link." | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |