Skip to content

feat: introduce Nix to Github Action #28

feat: introduce Nix to Github Action

feat: introduce Nix to Github Action #28

Workflow file for this run

name: Build releases
on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"
paths:
- ".github/workflows/build.yaml"
- ".vitepress/**"
- "src/**"
- "theme/**"
- "book.toml"
- "package-lock.json"
- "package.json"
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: "build"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install nix
uses: cachix/install-nix-action@v26
with:
nix_path: "${{ matrix.nixPath }}"
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Setup cachix
uses: cachix/cachix-action@v14
with:
name: cryolitia
extraPullNames: nix-community
- name: Setup Github Caches
uses: DeterminateSystems/magic-nix-cache-action@v4
- name: Build
run: |
sed -e "s/BUILD_TIME/$(TZ=Asia/Shanghai date -Isecond)/" -e "s/COMMIT_SHA/${{ github.sha }}/" -i src/about.md
NIXPKGS_ALLOW_UNFREE=1 nix build .# --impure -v -L
- uses: actions/upload-artifact@v4
with:
name: transky-book.epub
path: |
result/**/*.epub
result/**/*.pdf
result/**/*.mobi
- uses: actions/upload-artifact@v4
with:
name: transky-book.pdf
path: |
result/**/*.pdf
- uses: actions/upload-artifact@v4
with:
name: transky-book.mobi
path: |
result/**/*.mobi
- name: Release eBook
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ github.token }}
run: exit0 || pnpm exec semantic-release