Skip to content

Nix Package

Nix Package #7

Workflow file for this run

name: Nix CI
on:
push:
pull_request:
jobs:
check-hashes:
name: Ensure Nix Hashes are up-to-date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if relevant files changed
shell: bash
run: |
# most sane regex
# checks if one of these files/directories has been touched
# - package.json
# - package-lock.json
# - nix/
# - composer.json
# - composer.lock
if [ -n "$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -P '^(?:package(?:-lock)?\.json$|nix\/|composer\.(?:json|lock)$')" ]; then
echo "File(s) changed so this job runs"
else
echo "no files changed so we exit neutrally (not success or failure)"
exit 78
fi
- name: Install nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
# - uses: cachix/cachix-action@v12
# with:
# name: trawelling
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Update generated files
run: nix develop --impure .#ci --command "update-nix-package-deps"
- name: Check if up-to-date
shell: bash
id: check
run: |
if [[ ! -z $(git status -s) ]]; then
git status
echo "up-to-date=false" >> "$GITHUB_OUTPUT"
fi
- name: Find Comment
uses: peter-evans/find-comment@v2
if: "github.event_name == 'pull_request' && steps.check.outputs.up-to-date == 'false'"
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This comment was written by a bot!
- name: Create comment
if: "steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && steps.check.outputs.up-to-date == 'false'"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
The composer or npm dependencies are out of sync with the generated nix files.
Please update the files by either running the `update-nix-package-dep` script locally
or let GitHub actions do it by running `/nix-update`.
*This comment was written by a bot!* 🤖
- name: Fail Build
if: "steps.check.outputs.up-to-date == 'false'"
shell: bash
run: exit 1
build:
name: Build Package
runs-on: ubuntu-latest
needs:
- check-hashes
steps:
- uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
# - uses: cachix/cachix-action@v12
# with:
# name: trawelling
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build with nix
run: nix build