Skip to content

Commit

Permalink
Deploy website to IPFS
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaharagon committed Apr 8, 2024
1 parent 9626aab commit cf072cd
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 119 deletions.
93 changes: 0 additions & 93 deletions .github/workflows/build-offline.yml

This file was deleted.

75 changes: 64 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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/[email protected]
with:
Expand All @@ -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
16 changes: 8 additions & 8 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 1 addition & 3 deletions config/mkdocs-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ watch:
plugins:
tags: {}
search: {}
privacy:
assets_exclude:
- cdn.jsdelivr.net/npm/mathjax@3/*
privacy: {}

markdown_extensions:
admonition: {}
Expand Down
4 changes: 1 addition & 3 deletions config/mkdocs-offline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion theme/partials/copyright.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit cf072cd

Please sign in to comment.