Skip to content

Commit

Permalink
Remove per-language config files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaharagon committed Apr 10, 2024
1 parent 1acdf17 commit 8165750
Show file tree
Hide file tree
Showing 24 changed files with 378 additions and 483 deletions.
1 change: 1 addition & 0 deletions .cache/plugin/social/fonts
1 change: 0 additions & 1 deletion .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
name: ☁️ Build Container

Check warning on line 1 in .github/workflows/build-container.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

1:1 [document-start] missing document start "---"

Check warning on line 1 in .github/workflows/build-container.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

1:1 [document-start] missing document start "---"

# Configures this workflow to run every time a change is pushed to the branch called `release`.
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: 🛠️ Build PR Preview

Check warning on line 1 in .github/workflows/build-pr.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

1:1 [document-start] missing document start "---"

Check warning on line 1 in .github/workflows/build-pr.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

1:1 [document-start] missing document start "---"

on:

Check warning on line 3 in .github/workflows/build-pr.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

3:1 [truthy] truthy value should be one of [false, true]

Check warning on line 3 in .github/workflows/build-pr.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

3:1 [truthy] truthy value should be one of [false, true]
pull_request:

concurrency:
group: ${{github.event.pull_request.head.ref}}
cancel-in-progress: true

permissions:
contents: read

jobs:
metadata:
runs-on: ubuntu-latest
outputs:
submodules: ${{ steps.submodules.outputs.submodules }}
privileged: ${{ steps.submodules.outputs.privileged }}
matrix: ${{ steps.matrix-fork.outputs.matrix || steps.matrix-main.outputs.matrix }}
env:
ACTIONS_SSH_KEY: ${{ secrets.ACTIONS_SSH_KEY }}
steps:
- name: Set matrix for fork
if: env.ACTIONS_SSH_KEY == ''
id: matrix-fork
uses: druzsan/setup-matrix@v2
with:
matrix: |
repo: [brand, i18n]
- name: Set matrix for main repo
if: env.ACTIONS_SSH_KEY != ''
id: matrix-main
uses: druzsan/setup-matrix@v2
with:
matrix: |
repo: [brand, i18n, mkdocs-material-insiders]
- name: Set submodules for fork
if: env.ACTIONS_SSH_KEY == ''
id: submodules
run: |
echo "submodules="[brand, i18n]"" >> "$GITHUB_OUTPUT"
echo "privileged=false" >> "$GITHUB_OUTPUT"
- name: Set submodules for main repo
if: env.ACTIONS_SSH_KEY != ''
run: |
echo "submodules="[brand, i18n, webserver]"" >> "$GITHUB_OUTPUT"
echo "privileged=true" >> "$GITHUB_OUTPUT"
- name: Save PR metadata
run: |
mkdir -p ./metadata
echo ${{ github.event.number }} > ./metadata/NR
echo ${{ github.event.pull_request.head.sha }} > ./metadata/SHA
- name: Upload metadata as artifact
uses: actions/upload-artifact@v4
with:
name: metadata
path: metadata

submodule:
needs: metadata
strategy:
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }}
uses: privacyguides/.github/.github/workflows/download-repo.yml@main
with:
repo: ${{ matrix.repo.name }}
privileged: ${{ fromJSON(needs.metadata.outputs.privileged) }}
secrets:
ACTIONS_SSH_KEY: ${{ secrets.ACTIONS_SSH_KEY }}

build:
needs: [submodule, metadata]
strategy:
matrix:
lang: [es, fr, he, it, nl, ru, zh-Hant]
allow-error: [true]
include:
- lang: en
allow-error: false
fail-fast: false
uses: ./.github/workflows/build.yml
with:
ref: ${{github.event.pull_request.head.ref}}
repo: ${{github.event.pull_request.head.repo.full_name}}
lang: ${{ matrix.lang }}
continue-on-error: ${{ matrix.allow-error }}
privileged: ${{ fromJSON(needs.metadata.outputs.privileged) }}

combine_build:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: site-build-*
merge-multiple: true

- run: |
for file in *.tar.gz; do tar -zxf "$file"; done
ls -la site/
- name: Upload Site
uses: actions/upload-artifact@v4
with:
name: site-build-combined
path: site
retention-days: 5

cleanup:
if: ${{ always() }}
needs: build
uses: privacyguides/.github/.github/workflows/cleanup.yml@main
130 changes: 109 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
continue-on-error:
type: boolean
default: true
privileged:
type: boolean
default: true

permissions:
contents: read
Expand All @@ -33,51 +36,111 @@ jobs:
contents: read

steps:
- run: |
- name: Add GitHub Token to Environment
run: |
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> "$GITHUB_ENV"
- if: inputs.config == 'build'
- name: Set Metadata
if: inputs.config == 'build'
run: |
{
echo "MKDOCS_INHERIT=mkdocs-production.yml"
echo "BUILD_CONTEXT=${{ inputs.context }}"
echo "BUILD_EDIT_URI_TEMPLATE=blob/main/docs/{path}?plain=1"
echo "BUILD_REPO_URL=https://github.com/privacyguides/privacyguides.org"
echo "PRODUCTION=true"
echo "CONTEXT=${{ inputs.context }}"
} >> "$GITHUB_ENV"
- if: inputs.config == 'offline'
- name: Set Metadata for Privileged Builds
if: inputs.privileged
run: echo "BUILD_INSIDERS=true" >> "$GITHUB_ENV"

- name: Set Metadata for Offline Mode
if: inputs.config == 'offline'
run: |
{
echo "BUILD_OFFLINE=true"
echo "BUILD_REPO_URL=""
echo "CARDS=false"
echo "HOMEPAGE_BUTTON_GET_STARTED_LINK=basics/why-privacy-matters.html"
echo "HOMEPAGE_BUTTON_TOOLS_LINK=tools.html"
} >> "$GITHUB_ENV"
- name: Set Metadata for Translations
if: inputs.lang != 'en'
run: |
{
echo "BUILD_ABBREVIATIONS=includes/abbreviations.${{ inputs.lang }}.txt"
echo "BUILD_DOCS_DIR=i18n/${{ inputs.lang }}"
echo "BUILD_EDIT_URI_TEMPLATE=https://github.com/privacyguides/i18n/blob/main/i18n/${{ inputs.lang }}/{path}?plain=1"
echo "BUILD_SITE_DIR=i18n/${{ inputs.lang }}"
echo "BUILD_SITE_URL=https://privacyguides.org/${{ inputs.lang }}"
echo "BUILD_THEME_LANGUAGE=${{ inputs.lang }}"
} >> "$GITHUB_ENV"
- name: Set Metadata for Hebrew Translation
if: inputs.lang == 'he'
run: |
{
echo "BUILD_THEME_FONT_CODE=Cousine"
echo "BUILD_THEME_FONT_TEXT=Open Sans"
echo "TRANSLATION_STYLESHEET=assets/stylesheets/lang-${{ inputs.lang }}.css?v=20240410"
} >> "$GITHUB_ENV"
- name: Set Metadata for Russian Translation
if: inputs.lang == 'ru'
run: |
{
echo "TRANSLATION_STYLESHEET=assets/stylesheets/lang-${{ inputs.lang }}.css?v=20240410"
} >> "$GITHUB_ENV"
- name: Set Metadata for Chinese (Traditional) Translation
if: inputs.lang == 'zh-Hant'
run: |
echo "MKDOCS_INHERIT=mkdocs-offline.yml" >> "$GITHUB_ENV"
echo "CARDS=false" >> "$GITHUB_ENV"
{
echo "BUILD_THEME_FONT_CODE=Noto Sans TC"
echo "BUILD_THEME_FONT_TEXT=Noto Sans TC"
echo "TRANSLATION_STYLESHEET=assets/stylesheets/lang-${{ inputs.lang }}.css?v=20240410"
} >> "$GITHUB_ENV"
- uses: actions/checkout@v4
- name: Download Repository
uses: actions/checkout@v4
with:
repository: ${{ inputs.repo }}
ref: ${{ inputs.ref }}
persist-credentials: "false"
fetch-depth: 0

- uses: actions/download-artifact@v4
- name: Download Submodules
uses: actions/download-artifact@v4
with:
pattern: repo-*
path: modules

- run: |
- name: Move mkdocs-material-insiders to mkdocs-material
if: inputs.privileged
run: |
rmdir modules/mkdocs-material
mv modules/repo-mkdocs-material-insiders modules/mkdocs-material
- name: Move brand submodule to theme/assets/brand
run: |
rmdir theme/assets/brand
mv modules/repo-brand theme/assets/brand
- if: inputs.lang != 'en'
- name: Copy Translation Files
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
- name: Install Python
uses: actions/setup-python@v5
with:
cache: "pipenv"

- uses: actions/cache/[email protected]
- name: Restore Site Cache
uses: actions/cache/[email protected]
id: site_cache_restore
with:
key: site-cache-${{ inputs.repo }}-${{ inputs.ref }}-${{ hashfiles('.cache/**') }}
Expand All @@ -86,7 +149,8 @@ jobs:
site-cache-${{ inputs.repo }}-${{ inputs.ref }}-
site-cache-${{ inputs.repo }}-
- uses: actions/cache/[email protected]
- name: Restore Card Cache
uses: actions/cache/[email protected]
id: card_cache_restore
with:
key: card-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-${{ hashfiles('config/.cache/plugin/social/manifest.json') }}
Expand All @@ -97,40 +161,64 @@ jobs:
card-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-
card-cache-${{ inputs.repo }}-${{ inputs.lang }}-
- run: |
- name: Install Python Dependencies
if: inputs.privileged
run: |
pip install pipenv
pipenv install
sudo apt install pngquant
- uses: falti/[email protected]
- name: Install Python Dependencies (Unprivileged)
if: ${{ !inputs.privileged }}
run: |
pip install mkdocs-material
sudo apt install pngquant
- name: Set Translated String Environment Variables
uses: falti/[email protected]
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
- name: Build Website
if: inputs.privileged
run: |
pipenv run mkdocs build --config-file mkdocs-production.yml
pipenv run mkdocs --version
- name: Build Website (Unprivileged)
if: ${{ !inputs.privileged }}
run: |
mkdocs build --config-file ${{ inputs.config_file }}
mkdocs --version
- name: Package Website
run: |
tar -czvf site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz site
- uses: actions/cache/[email protected]
- name: Save Site Cache
uses: actions/cache/[email protected]
if: steps.site_cache_restore.outputs.cache-hit != 'true'
with:
key: site-cache-${{ inputs.repo }}-${{ inputs.ref }}-${{ hashfiles('.cache/**') }}
path: .cache

- uses: actions/cache/[email protected]
- name: Save Card Cache
uses: actions/cache/[email protected]
if: steps.card_cache_restore.outputs.cache-hit != 'true'
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
- name: Upload Site
uses: actions/upload-artifact@v4
with:
name: site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz
path: site-${{ inputs.config }}-${{ inputs.lang }}.tar.gz
retention-days: 1

offline_package:
if: inputs.config == 'offline' && inputs.lang == 'en'
Expand Down
Loading

0 comments on commit 8165750

Please sign in to comment.