-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../theme/assets/brand/fonts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: 🛠️ Build PR Preview | ||
Check warning on line 1 in .github/workflows/build-pr.yml GitHub Actions / MegaLinter
Check warning on line 1 in .github/workflows/build-pr.yml GitHub Actions / MegaLinter
|
||
|
||
on: | ||
Check warning on line 3 in .github/workflows/build-pr.yml GitHub Actions / MegaLinter
Check warning on line 3 in .github/workflows/build-pr.yml GitHub Actions / MegaLinter
|
||
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-fork.outputs.submodules || steps.submodules-main.outputs.submodules }} | ||
privileged: ${{ steps.submodules-fork.outputs.privileged || steps.submodules-main.outputs.privileged }} | ||
env: | ||
ACTIONS_SSH_KEY: ${{ secrets.ACTIONS_SSH_KEY }} | ||
steps: | ||
- name: Set submodules for fork | ||
if: env.ACTIONS_SSH_KEY == '' | ||
id: submodules-fork | ||
run: | | ||
echo 'submodules={"repo":["brand","i18n"]}' >> "$GITHUB_OUTPUT" | ||
echo "privileged=false" >> "$GITHUB_OUTPUT" | ||
- name: Set submodules for main repo | ||
if: env.ACTIONS_SSH_KEY != '' | ||
id: submodules-main | ||
run: | | ||
echo 'submodules={"repo":["brand","i18n","mkdocs-material-insiders"]}' >> "$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.submodules) }} | ||
uses: privacyguides/.github/.github/workflows/download-repo.yml@main | ||
with: | ||
repo: ${{ matrix.repo }} | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build Website | ||
name: 🛠️ Build Website | ||
Check warning on line 1 in .github/workflows/build.yml GitHub Actions / MegaLinter
Check warning on line 1 in .github/workflows/build.yml GitHub Actions / MegaLinter
|
||
|
||
on: | ||
Check warning on line 3 in .github/workflows/build.yml GitHub Actions / MegaLinter
Check warning on line 3 in .github/workflows/build.yml GitHub Actions / MegaLinter
|
||
workflow_call: | ||
|
@@ -21,6 +21,9 @@ on: | |
continue-on-error: | ||
type: boolean | ||
default: true | ||
privileged: | ||
type: boolean | ||
default: true | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -33,51 +36,112 @@ 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_EDIT_URI_TEMPLATE=''" | ||
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=site/${{ 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/**') }} | ||
|
@@ -86,7 +150,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') }} | ||
|
@@ -97,40 +162,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 | ||
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' | ||
|