Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Github Actions中使用Nix来管理所有包 #11

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions .github/workflows/scheduled_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,13 @@ jobs:
COVER_PDF_PATH: resources/cover.pdf
steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
- name: install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- uses: cachix/install-nix-action@v30
- name: build pdf
run: python main_async.py
run: nix develop --command 'python main_async.py'
- name: optimize pdf size
run: |
mkdir pdfsizeopt
cd pdfsizeopt
wget -O pdfsizeopt_libexec_linux.tar.gz https://github.com/pts/pdfsizeopt/releases/download/2023-04-18/pdfsizeopt_libexec_linux-v9.tar.gz
tar xzvf pdfsizeopt_libexec_linux.tar.gz
rm -f pdfsizeopt_libexec_linux.tar.gz
wget -O pdfsizeopt.single https://raw.githubusercontent.com/pts/pdfsizeopt/master/pdfsizeopt.single
chmod +x pdfsizeopt.single
ln -s pdfsizeopt.single pdfsizeopt
cd ..
mv out/guide.pdf .
./pdfsizeopt/pdfsizeopt guide.pdf out/guide.pdf
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out/guide.pdf guide.pdf
- name: build redirect page
run: cp resources/index.html out/index.html
- name: upload
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
description = "ACSSZ guide for new students and scholars";

# TODO 使用上游仓库
inputs.nixpkgs.url = "github:yoctocell/nixpkgs/add-python-lark-oapi";

outputs = { self, nixpkgs }:
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
in with pkgs; {
devShell.x86_64-linux = mkShell {
name = "acssz-guide";
buildInputs = [
# For compressing pdfs, see <https://askubuntu.com/a/256449>
ghostscript
pkgs.python3Packages.pymupdf
(pkgs.python3.withPackages (pp: with pp; [
requests
websockets
lark-oapi
]))
];
};
};
}