mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-18 09:01:12 -06:00
Improve website deployment (#139)
* Fix issue of book not building * add dependencies * fix * test make4ht * fix cmd * Use own docker image * Add label * fix urls * Add validate command * build non mac version * tmp run * use smaller tex version * build full
This commit is contained in:
committed by
GitHub
parent
62a9e9a000
commit
509092c56e
45
.github/workflows/build-image.yml
vendored
Normal file
45
.github/workflows/build-image.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Create and publish a Docker image
|
||||
|
||||
#on:
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
59
.github/workflows/main.yml
vendored
59
.github/workflows/main.yml
vendored
@@ -1,59 +0,0 @@
|
||||
name: Release LaTeX Document
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build_and_release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Bake the book
|
||||
uses: xu-cheng/texlive-action/full@v1
|
||||
with:
|
||||
run: |
|
||||
apk add make zip tidyhtml
|
||||
wget https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz
|
||||
tar xzf kindlegen_linux_2.6_i386_v2_9.tar.gz
|
||||
mv kindlegen /usr/bin
|
||||
cd book
|
||||
make bake
|
||||
- name: Release baked book to S3
|
||||
uses: shallwefootball/s3-upload-action@master
|
||||
with:
|
||||
aws_key_id: ${{ secrets.AWS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
||||
aws_bucket: ${{ secrets.AWS_BUCKET_BOOK }}
|
||||
source_dir: book/release
|
||||
destination_dir: release
|
||||
- name: Bake the website
|
||||
uses: xu-cheng/texlive-action/full@v1
|
||||
with:
|
||||
run: |
|
||||
apk add make zip tidyhtml
|
||||
make website
|
||||
- name: Release baked website to S3
|
||||
uses: shallwefootball/s3-upload-action@master
|
||||
with:
|
||||
aws_key_id: ${{ secrets.AWS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
||||
aws_bucket: ${{ secrets.AWS_BUCKET_WEBSITE }}
|
||||
source_dir: book/static_website_html
|
||||
destination_dir: static_html_root
|
||||
- name: Invalidate Cloudfront book cache
|
||||
uses: chetan/invalidate-cloudfront-action@v2
|
||||
env:
|
||||
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_BOOK }}
|
||||
PATHS: "/*"
|
||||
AWS_REGION: "us-east-1"
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
- name: Invalidate Cloudfront website cache
|
||||
uses: chetan/invalidate-cloudfront-action@v2
|
||||
env:
|
||||
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_WEBSITE }}
|
||||
PATHS: "/*"
|
||||
AWS_REGION: "us-east-1"
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
32
.github/workflows/release-book.yml
vendored
Normal file
32
.github/workflows/release-book.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Release the book
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build_and_release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Bake the book
|
||||
uses: docker://ghcr.io/hendricius/the-sourdough-framework:latest
|
||||
with:
|
||||
run: |
|
||||
make bake
|
||||
- name: Release baked book to S3
|
||||
uses: shallwefootball/s3-upload-action@master
|
||||
with:
|
||||
aws_key_id: ${{ secrets.AWS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
||||
aws_bucket: ${{ secrets.AWS_BUCKET_BOOK }}
|
||||
source_dir: book/release
|
||||
destination_dir: release
|
||||
- name: Invalidate Cloudfront book cache
|
||||
uses: chetan/invalidate-cloudfront-action@v2
|
||||
env:
|
||||
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_BOOK }}
|
||||
PATHS: "/*"
|
||||
AWS_REGION: "us-east-1"
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
32
.github/workflows/release-website.yml
vendored
Normal file
32
.github/workflows/release-website.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Release the website
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build_and_release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Bake the book
|
||||
uses: docker://ghcr.io/hendricius/the-sourdough-framework:latest
|
||||
with:
|
||||
run: |
|
||||
make website
|
||||
- name: Release baked website to S3
|
||||
uses: shallwefootball/s3-upload-action@master
|
||||
with:
|
||||
aws_key_id: ${{ secrets.AWS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
||||
aws_bucket: ${{ secrets.AWS_BUCKET_WEBSITE }}
|
||||
source_dir: book/static_website_html
|
||||
destination_dir: static_html_root
|
||||
- name: Invalidate Cloudfront website cache
|
||||
uses: chetan/invalidate-cloudfront-action@v2
|
||||
env:
|
||||
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_WEBSITE }}
|
||||
PATHS: "/*"
|
||||
AWS_REGION: "us-east-1"
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
6
.github/workflows/validate.yml
vendored
6
.github/workflows/validate.yml
vendored
@@ -7,12 +7,8 @@ jobs:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Test baking the release versions
|
||||
uses: xu-cheng/texlive-action/full@v1
|
||||
uses: docker://ghcr.io/hendricius/the-sourdough-framework:latest
|
||||
with:
|
||||
run: |
|
||||
apk add make zip tidyhtml
|
||||
wget https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz
|
||||
tar xzf kindlegen_linux_2.6_i386_v2_9.tar.gz
|
||||
mv kindlegen /usr/bin
|
||||
cd book
|
||||
make -j build_pdf build_serif_ebook
|
||||
|
||||
57
Dockerfile
57
Dockerfile
@@ -1,19 +1,48 @@
|
||||
FROM ghcr.io/xu-cheng/texlive-full
|
||||
FROM ubuntu:latest
|
||||
|
||||
WORKDIR /root
|
||||
LABEL "maintainer"="Hendrik Kleinwächter <hendrik.kleinwaechter@gmail.com>"
|
||||
LABEL "repository"="https://github.com/hendricius/the-sourdough-framework"
|
||||
LABEL "homepage"="https://github.com/hendricius/the-sourdough-framework"
|
||||
LABEL org.opencontainers.image.source="https://github.com/hendricius/the-sourdough-framework"
|
||||
|
||||
RUN apk add make zip tidyhtml git sudo pandoc
|
||||
RUN wget https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz
|
||||
RUN tar xzf kindlegen_linux_2.6_i386_v2_9.tar.gz
|
||||
RUN mv kindlegen /usr/bin
|
||||
RUN git clone https://github.com/michal-h21/tex4ebook.git
|
||||
WORKDIR /root/tex4ebook
|
||||
RUN make
|
||||
RUN make install
|
||||
WORKDIR /root
|
||||
# Install base depdendencies
|
||||
RUN apt-get update && \
|
||||
apt-get install --yes -y --no-install-recommends \
|
||||
make \
|
||||
tidy \
|
||||
pandoc \
|
||||
zip \
|
||||
git \
|
||||
wget
|
||||
|
||||
WORKDIR /opt/the-sourdough-framework
|
||||
# Install LaTeX
|
||||
RUN apt-get install --yes -y --no-install-recommends \
|
||||
texlive-full \
|
||||
texlive-lang-all
|
||||
|
||||
COPY . .
|
||||
# Install LaTeX extras
|
||||
RUN apt-get install --yes -y --no-install-recommends \
|
||||
latexmk \
|
||||
lmodern \
|
||||
fonts-lmodern \
|
||||
tex-gyre \
|
||||
fonts-texgyre \
|
||||
dvisvgm \
|
||||
context
|
||||
|
||||
CMD ["/bin/sh"]
|
||||
RUN apt-get autoclean && apt-get --purge --yes autoremove
|
||||
|
||||
# Custom TeX packages on latest version
|
||||
RUN git clone https://github.com/michal-h21/make4ht && \
|
||||
cd make4ht && \
|
||||
make justinstall SUDO=""
|
||||
|
||||
RUN git clone https://github.com/michal-h21/tex4ebook.git && \
|
||||
cd tex4ebook && \
|
||||
make && \
|
||||
make install SUDO=""
|
||||
|
||||
# Support to build amazon kindle books
|
||||
RUN wget https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz && \
|
||||
tar xzf kindlegen_linux_2.6_i386_v2_9.tar.gz && \
|
||||
mv kindlegen /usr/bin
|
||||
|
||||
@@ -221,9 +221,6 @@ release_sans_serif: build_sans_serif_pdf build_sans_serif_ebook | make_release_d
|
||||
|
||||
.PHONY: website
|
||||
website:
|
||||
if command -v cowsay &> /dev/null; then\
|
||||
cowsay "baking the website";\
|
||||
fi
|
||||
rm -rf $(WEBSITE_DIR)
|
||||
make4ht -c website.cfg -a debug -uf html5+tidy+common_domfilters+dvisvgm_hashes -d $(WEBSITE_DIR) book.tex
|
||||
mv $(WEBSITE_DIR)/book.html $(WEBSITE_DIR)/index.html
|
||||
|
||||
22
makefile
22
makefile
@@ -1,11 +1,25 @@
|
||||
PHONY: build_pdf
|
||||
DOCKER_IMAGE := ghcr.io/hendricius/the-sourdough-framework
|
||||
|
||||
.PHONY: build_pdf
|
||||
build_pdf: build_docker_image
|
||||
docker run -it -v $(PWD):/opt/repo the-sourdough-framework /bin/bash -c "cd /opt/repo/book && make build_pdf"
|
||||
docker run -it -v $(PWD):/opt/repo $(DOCKER_IMAGE) /bin/bash -c "cd /opt/repo/book && make"
|
||||
|
||||
.PHONY: bake
|
||||
bake: build_docker_image
|
||||
docker run -it -v $(PWD):/opt/repo the-sourdough-framework /bin/bash -c "cd /opt/repo/book && make bake"
|
||||
docker run -it -v $(PWD):/opt/repo $(DOCKER_IMAGE) /bin/bash -c "cd /opt/repo/book && make bake"
|
||||
|
||||
.PHONY: build_docker_image
|
||||
build_docker_image:
|
||||
docker build -t the-sourdough-framework -f Dockerfile .
|
||||
docker build -t $(DOCKER_IMAGE) -f Dockerfile --platform linux/amd64 .
|
||||
|
||||
.PHONY: push_docker_image
|
||||
push_docker_image:
|
||||
docker push $(DOCKER_IMAGE):latest
|
||||
|
||||
.PHONY: website
|
||||
website:
|
||||
docker run -it -v $(PWD):/opt/repo $(DOCKER_IMAGE) /bin/bash -c "cd /opt/repo/book && make website"
|
||||
|
||||
.PHONY: validate
|
||||
validate:
|
||||
docker run -it -v $(PWD):/opt/repo $(DOCKER_IMAGE) /bin/bash -c "cd /opt/repo/book && make -j build_pdf build_serif_ebook"
|
||||
|
||||
Reference in New Issue
Block a user