From 15d417410edb559714d9d8dd3f2bec0aed61352d Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 10 Feb 2023 12:40:12 +0800 Subject: [PATCH] Add GitHub action to generate static html for readability and distiller test pages --- .github/workflows/static.yml | 64 +++++++++++++++++++ .../test/{view.py => generate_static.py} | 0 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/static.yml rename packages/readabilityjs/test/{view.py => generate_static.py} (100%) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 000000000..9ded17ecd --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,64 @@ +# Simple workflow for generating and deploying static html in readability folder to GitHub Pages +name: Deploy static content to Pages + +on: + push: + branches: ["main"] + + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + generate-distiller-output: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: Generate distiller output for readability + run: | + go get github.com/omnivore-app/go-domdistiller + for f in packages/readabilityjs/test/test-pages/*/source.html; do + echo "Processing $f file..." + go-domdistiller -input $f -output $f.distiller.html + done + generate-static: + needs: generate-distiller-output + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Generate static html + run: | + cd packages/readabilityjs/test + python generate_static.py + deploy: + needs: generate-static + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Setup Pages + uses: actions/configure-pages@v3 + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: 'packages/readabilityjs/test/index.html' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 + diff --git a/packages/readabilityjs/test/view.py b/packages/readabilityjs/test/generate_static.py similarity index 100% rename from packages/readabilityjs/test/view.py rename to packages/readabilityjs/test/generate_static.py