mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2024-10-01 01:35:57 -04:00
172 lines
5.2 KiB
YAML
172 lines
5.2 KiB
YAML
name: Build Website
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
config:
|
|
type: string
|
|
default: build
|
|
ref:
|
|
required: true
|
|
type: string
|
|
repo:
|
|
required: true
|
|
type: string
|
|
lang:
|
|
type: string
|
|
default: en
|
|
context:
|
|
type: string
|
|
default: deploy-preview
|
|
continue-on-error:
|
|
type: boolean
|
|
default: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: ${{ inputs.continue-on-error }}
|
|
permissions:
|
|
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 }}
|
|
ref: ${{ inputs.ref }}
|
|
persist-credentials: "false"
|
|
fetch-depth: 0
|
|
|
|
- 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
|
|
|
|
- if: inputs.lang != 'en'
|
|
run: |
|
|
cp -rl modules/repo-i18n/i18n .
|
|
cp -rl modules/repo-i18n/includes .
|
|
cp -rl modules/repo-i18n/theme .
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
cache: "pipenv"
|
|
|
|
- uses: actions/cache/restore@v4.0.2
|
|
with:
|
|
key: site-cache-${{ inputs.repo }}-${{ inputs.ref }}-${{ hashfiles('.cache/**') }}
|
|
path: .cache
|
|
restore-keys: |
|
|
site-cache-${{ inputs.repo }}-${{ inputs.ref }}-
|
|
site-cache-${{ inputs.repo }}-
|
|
|
|
- uses: actions/cache/restore@v4.0.2
|
|
with:
|
|
key: card-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-${{ hashfiles('config/.cache/plugin/social/manifest.json') }}
|
|
path: |
|
|
config/.cache/plugin/social/manifest.json
|
|
config/.cache/plugin/social/assets
|
|
restore-keys: |
|
|
card-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-
|
|
card-cache-${{ inputs.repo }}-${{ inputs.lang }}-
|
|
|
|
- run: |
|
|
pip install pipenv
|
|
pipenv install
|
|
sudo apt install pngquant
|
|
|
|
- uses: falti/dotenv-action@v1.1
|
|
with:
|
|
path: includes/strings.${{ inputs.lang }}.env
|
|
export-variables: true
|
|
keys-case: bypass
|
|
|
|
- run: |
|
|
pipenv run mkdocs build --config-file config/mkdocs.${{ inputs.lang }}.yml
|
|
pipenv run mkdocs --version
|
|
tar -czvf site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz site
|
|
|
|
- uses: actions/cache/save@v4.0.2
|
|
with:
|
|
key: site-cache-${{ inputs.repo }}-${{ inputs.ref }}-${{ hashfiles('.cache/**') }}
|
|
path: .cache
|
|
|
|
- uses: actions/cache/save@v4.0.2
|
|
with:
|
|
key: card-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-${{ hashfiles('config/.cache/plugin/social/manifest.json') }}
|
|
path: |
|
|
config/.cache/plugin/social/manifest.json
|
|
config/.cache/plugin/social/assets
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
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
|