Skip to content

Commit

Permalink
Use build-image and support OpenDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
foxyseta committed Jun 5, 2023
1 parent 4037ac2 commit eebb532
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 8 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,20 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: statik
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download static site artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: statik-build
name: build
path: site
- name: Setup Pages
uses: actions/configure-pages@v1
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@main
uses: actions/deploy-pages@v1
115 changes: 115 additions & 0 deletions .github/workflows/build-and-deploy.yml.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build and Deploy
on:
push:
branches: main
pull_request:
branches: main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

env:
REGEX_INCLUDE: "\\.(pdf|link|txt)$"

jobs:
build:
name: Build pdfs out of tex,md and various doc files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install tex
run: |
sudo apt update
sudo apt install texlive-latex-extra texlive-lang-italian texlive-lang-english texlive-fonts-recommended texlive-bibtex-extra texlive-science texlive-xetex

- name: Install format conversion tools
run: |
sudo apt install libreoffice
wget https://github.com/jgm/pandoc/releases/download/2.18/pandoc-2.18-linux-amd64.tar.gz -O /tmp/pandoc.tar.gz
tar xfz /tmp/pandoc.tar.gz -C /tmp
sudo mv /tmp/pandoc-*/bin/* /usr/bin

- name: Recursively compile tex files
run: ./.github/workflows/rec "*\.tex$" "xelatex -pdf"

- name: Recursively compile (doc|ppt)x? files
run: ./.github/workflows/rec "*\.((doc|ppt)x?)|odt$" "libreoffice --headless --convert-to pdf --outdir ."

- name: Recursively compile md files
run: ./.github/workflows/rec "*\.md$" ${GITHUB_WORKSPACE}/.github/workflows/md2pdf

- name: Generate build artifact
uses: actions/upload-artifact@v2
with:
name: build-result
path: .

statik:
name: Generate the static listing
runs-on: ubuntu-latest
needs: build
steps:
- name: Download compiled files
uses: actions/download-artifact@v2
with:
name: build-result

- name: Install go
uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"

- name: Install statik
run: go install github.com/lucat1/statik@latest

- name: Update packages and install rsync
run: sudo apt install rsync

- name: Generate static directory listing
run: $(go env GOPATH)/bin/statik -page .github/workflows/page.gohtml -l -b "https://${{ github.event.repository.owner.name }}.github.io/${{ github.event.repository.name }}/" -i "$REGEX_INCLUDE" site

- name: Generate site artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v2
with:
name: statik-build
path: ./site

deploy:
name: Deploy to Github Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: statik
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download static site artifact
uses: actions/download-artifact@v2
with:
name: statik-build
path: site
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@main
83 changes: 83 additions & 0 deletions .github/workflows/build-and-deploy.yml.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
--- .github/workflows/build-and-deploy.yml
+++ .github/workflows/build-and-deploy.yml
@@ -23,69 +23,35 @@ env:

jobs:
build:
- name: Build pdfs out of tex,md and various doc files
runs-on: ubuntu-latest
+ name: Build pdfs out of tex,md and various doc files
+ container:
+ image: ghcr.io/csunibo/build-image:latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- - name: Install tex
- run: |
- sudo apt update
- sudo apt install texlive-latex-extra texlive-lang-italian texlive-lang-english texlive-fonts-recommended texlive-bibtex-extra texlive-science texlive-xetex
-
- - name: Install format conversion tools
- run: |
- sudo apt install libreoffice
- wget https://github.com/jgm/pandoc/releases/download/2.18/pandoc-2.18-linux-amd64.tar.gz -O /tmp/pandoc.tar.gz
- tar xfz /tmp/pandoc.tar.gz -C /tmp
- sudo mv /tmp/pandoc-*/bin/* /usr/bin
-
- name: Recursively compile tex files
- run: ./.github/workflows/rec "*\.tex$" "xelatex -pdf"
+ run: rec "\.tex$" "xelatex -pdf"

- name: Recursively compile (doc|ppt)x? files
- run: ./.github/workflows/rec "*\.(doc|ppt)x?$" "libreoffice --headless --convert-to pdf --outdir ."
+ run: rec "\.(((doc|ppt)x?)|od(t|p))$" "libreoffice --headless --convert-to pdf --outdir ."

- name: Recursively compile md files
- run: ./.github/workflows/rec "*\.md$" ${GITHUB_WORKSPACE}/.github/workflows/md2pdf
+ run: rec "\.md$" /usr/bin/md2pdf

- - name: Generate build artifact
- uses: actions/upload-artifact@v2
- with:
- name: build-result
- path: .
-
- statik:
- name: Generate the static listing
- runs-on: ubuntu-latest
- needs: build
- steps:
- - name: Download compiled files
- uses: actions/download-artifact@v2
- with:
- name: build-result
-
- - name: Install go
- uses: actions/setup-go@v3
- with:
- go-version: ">=1.18.0"
-
- - name: Install statik
- run: go install github.com/lucat1/statik@latest
-
- - name: Update packages and install rsync
- run: sudo apt install rsync
+ - name: Recursively compile xopp files
+ run: rec "\.xopp$" /usr/bin/xopp2pdf

- name: Generate static directory listing
- run: $(go env GOPATH)/bin/statik -page .github/workflows/page.gohtml -l -b "https://${{ github.event.repository.owner.name }}.github.io/${{ github.event.repository.name }}/" -i "$REGEX_INCLUDE" site
+ run: statik -page /usr/share/page.gohtml -l -b "https://${{ github.event.repository.owner.name }}.github.io/${{ github.event.repository.name }}/" -i "$REGEX_INCLUDE" site

- name: Generate site artifact
if: github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
- name: statik-build
+ name: build
path: ./site

deploy:
2 changes: 1 addition & 1 deletion .github/workflows/page.gohtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" prefix="og: https://ogp.me/ns#">
<head>
<meta name="viewport" content="width=device-width">
<meta property="og:title" content="{{ .Root.URL.Path }}" />
Expand Down

0 comments on commit eebb532

Please sign in to comment.