Run build CI action on pull requests #11
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Nix | |
| uses: cachix/install-nix-action@v31 | |
| - name: Format Nix files | |
| run: find -type f -name '*.nix' | xargs nix fmt -- --check --strict | |
| find-templates: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| templates: ${{ steps.set-templates.outputs.templates }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - id: set-templates | |
| run: | | |
| echo "templates=$(ls templates | jq -R '[.]' | jq -s -c 'add')" >> $GITHUB_OUTPUT | |
| instantiate-and-build: | |
| needs: find-templates | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| TEMPLATE: ${{ fromJson(needs.find-templates.outputs.templates) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Nix | |
| uses: cachix/install-nix-action@v31 | |
| - name: Create temporary folder | |
| run: TMPDIR=$RUNNER_TEMP/${{ matrix.TEMPLATE }} | |
| - name: Instantiate template | |
| run: (cd $TMPDIR && nix flake init --refresh --template $GITHUB_WORKSPACE#templates.${{ matrix.TEMPLATE }}) | |
| - name: Build template | |
| run: (cd $TMPDIR && nix build --override-input nixcaps $GITHUB_WORKSPACE) |