Deploy website to IPFS (#2502)

This commit is contained in:
Jonah Aragon 2024-04-08 15:20:31 -05:00
parent 9626aabea8
commit a1b01b8b8c
No known key found for this signature in database
6 changed files with 75 additions and 119 deletions

View File

@ -1,93 +0,0 @@
name: Build Offline Website
on:
workflow_call:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: "false"
- uses: actions/download-artifact@v4
with:
pattern: repo-*
path: modules
- run: |
rmdir modules/mkdocs-material
mv modules/repo-mkdocs-material-insiders modules/mkdocs-material
rmdir theme/assets/brand
mv modules/repo-brand theme/assets/brand
- name: Python setup
uses: actions/setup-python@v5
with:
cache: "pipenv"
- uses: actions/cache/restore@v4.0.2
with:
key: site-cache-${{ github.repository }}-en-${{ github.ref }}-${{ hashfiles('.cache/**') }}
path: .cache
restore-keys: |
site-cache-${{ github.repository }}-en-${{ github.ref }}-
site-cache-${{ github.repository }}-en-
- name: Install Python dependencies
run: |
pip install pipenv
pipenv install
sudo apt install pngquant
- name: Build website
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARDS: false
run: |
pipenv run mkdocs build --config-file config/mkdocs-offline.yml
pipenv run mkdocs --version
- name: Package website
run: |
tar -czvf offline.tar.gz site
zip -r -q offline.zip site
- uses: actions/cache/save@v4.0.2
with:
key: site-cache-${{ github.repository }}-en-${{ github.ref }}-${{ hashfiles('.cache/**') }}
path: .cache
- name: Upload tar.gz file
uses: actions/upload-artifact@v4
with:
name: offline.tar.gz
path: offline.tar.gz
- name: Upload zip file
uses: actions/upload-artifact@v4
with:
name: offline.zip
path: offline.zip
- name: Create ZIM File
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/openzim/zim-tools:3.1.3
options: -v ${{ github.workspace }}:/data
run: |
zimwriterfs -w index.html -I assets/brand/logos/png/square/pg-yellow.png -l eng -t "Privacy Guides" -d "Your central privacy and security resource to protect yourself online." -c "Privacy Guides" -p "Jonah Aragon" -n "Privacy Guides" -e "https://github.com/privacyguides/privacyguides.org" /data/site /data/offline-privacy_guides.zim
- name: Upload ZIM file
uses: actions/upload-artifact@v4
with:
name: offline-privacy_guides.zim
path: offline-privacy_guides.zim

View File

@ -3,9 +3,9 @@ name: Build Website
on:
workflow_call:
inputs:
base_config:
config:
type: string
default: mkdocs-production.yml
default: build
ref:
required: true
type: string
@ -33,6 +33,20 @@ jobs:
contents: read
steps:
- run: |
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- if: inputs.config == 'build'
run: |
echo "MKDOCS_INHERIT=mkdocs-production.yml" >> $GITHUB_ENV
echo "PRODUCTION=true" >> $GITHUB_ENV
echo "CONTEXT=${{ inputs.context }}" >> $GITHUB_ENV
- if: inputs.config == 'offline'
run: |
echo "MKDOCS_INHERIT=mkdocs-offline.yml" >> $GITHUB_ENV
echo "CARDS=false" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repo }}
@ -90,15 +104,10 @@ jobs:
export-variables: true
keys-case: bypass
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTEXT: ${{ inputs.context }}
MKDOCS_INHERIT: ${{ inputs.base_config }}
PRODUCTION: true
run: |
- run: |
pipenv run mkdocs build --config-file config/mkdocs.${{ inputs.lang }}.yml
pipenv run mkdocs --version
tar -czvf site-build-${{ inputs.lang }}.tar.gz site
tar -czvf site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz site
- uses: actions/cache/save@v4.0.2
with:
@ -114,5 +123,49 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: site-build-${{ inputs.lang }}.tar.gz
path: site-build-${{ inputs.lang }}.tar.gz
name: site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz
path: site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz
offline_package:
if: inputs.config == 'offline' && inputs.lang == 'en'
needs: build
runs-on: ubuntu-latest
continue-on-error: ${{ inputs.continue-on-error }}
permissions:
contents: read
steps:
- uses: actions/download-artifact@v4
with:
name: site-offline-en.tar.gz
- run: |
tar -xzvf site-offline-en.tar.gz
tar -czvf offline.tar.gz site/en
zip -r -q offline.zip site/en
- name: Upload tar.gz file
uses: actions/upload-artifact@v4
with:
name: offline.tar.gz
path: offline.tar.gz
- name: Upload zip file
uses: actions/upload-artifact@v4
with:
name: offline.zip
path: offline.zip
- name: Create ZIM File
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/openzim/zim-tools:3.1.3
options: -v ${{ github.workspace }}:/data
run: |
zimwriterfs -w index.html -I assets/brand/logos/png/square/pg-yellow.png -l eng -t "Privacy Guides" -d "Your central privacy and security resource to protect yourself online." -c "Privacy Guides" -p "Jonah Aragon" -n "Privacy Guides" -e "https://github.com/privacyguides/privacyguides.org" /data/site/en /data/offline-privacy_guides.zim
- name: Upload ZIM file
uses: actions/upload-artifact@v4
with:
name: offline-privacy_guides.zim
path: offline-privacy_guides.zim

View File

@ -51,25 +51,21 @@ jobs:
strategy:
matrix:
lang: [en, es, fr, he, it, nl, ru, zh-Hant]
build: [build, offline]
permissions:
contents: read
uses: ./.github/workflows/build.yml
with:
config: ${{ matrix.build }}
ref: ${{ github.ref }}
repo: ${{ github.repository }}
lang: ${{ matrix.lang }}
context: production
continue-on-error: false
buildoffline:
needs: submodule
permissions:
contents: read
uses: ./.github/workflows/build-offline.yml
release:
name: Create release notes
needs: buildoffline
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
@ -96,8 +92,12 @@ jobs:
PROD_MINIO_SECRET_KEY: ${{ secrets.PROD_MINIO_SECRET_KEY }}
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
CLUSTER_USERNAME: ${{ secrets.CLUSTER_USERNAME }}
CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
cleanup:
if: ${{ always() }}
needs: [build, buildoffline]
needs: build
uses: privacyguides/.github/.github/workflows/cleanup.yml@main

View File

@ -307,9 +307,7 @@ watch:
plugins:
tags: {}
search: {}
privacy:
assets_exclude:
- cdn.jsdelivr.net/npm/mathjax@3/*
privacy: {}
markdown_extensions:
admonition: {}

View File

@ -18,7 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
INHERIT: !ENV [MKDOCS_INHERIT, mkdocs-common.yml]
INHERIT: mkdocs-common.yml
# Disable any GitHub integrations
repo_url: ""
@ -54,8 +54,6 @@ extra:
class: md-button
theme:
# OFFLINE ONLY: this logo needs to be set separately because the relative path is different
logo: ../theme/assets/brand/logos/svg/logo/privacy-guides-logo-notext-colorbg.svg
features:
- navigation.tabs
- navigation.sections

View File

@ -24,7 +24,7 @@
<!-- Copyright information -->
<div class="md-copyright">
{% if copyright %}
<div class="md-copyright__highlight">
<div class="md-copyright__highlight" title="This version of Privacy Guides was built on {{ build_date_utc.strftime('%B %d, %Y at %I:%M%p') }}">
{{ copyright.intro }}
<br />
{{ copyright.note }}