Skip to content

Commit

Permalink
Use GitHub Actions instead of Netlify (#2462)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Gray <dngray@privacyguides.org>
  • Loading branch information
jonaharagon committed Mar 31, 2024
1 parent 0b43cb1 commit 353955f
Show file tree
Hide file tree
Showing 27 changed files with 516 additions and 1,424 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2023 Jonah Aragon <jonah@triplebit.net>
# Copyright (c) 2024 Jonah Aragon <jonah@triplebit.net>

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand All @@ -18,59 +18,50 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

name: 📦 Releases
name: Build Offline Website

on:
push:
tags:
- '*'
workflow_call:

permissions:
contents: read

jobs:
production:
name: Push release to production
build:
runs-on: ubuntu-latest
environment:
name: actions-ssh
permissions:
contents: write
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: '0'
ssh-key: ${{ secrets.ACTIONS_SSH_KEY }}
submodules: 'true'

- name: Push to production branch
run: |
git push origin HEAD:production
persist-credentials: 'false'

build:
name: Create release packages
runs-on: ubuntu-latest
environment:
name: actions-ssh

steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
fetch-depth: '0'
ssh-key: ${{ secrets.ACTIONS_SSH_KEY }}
submodules: 'true'
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:
python-version: '3.8'
cache: 'pipenv'

- name: Cache files
uses: actions/cache@v4.0.2
- uses: actions/cache/restore@v4.0.2
with:
key: ${{ github.ref }}
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: |
Expand All @@ -91,6 +82,11 @@ jobs:
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:
Expand All @@ -114,32 +110,5 @@ jobs:
- name: Upload ZIM file
uses: actions/upload-artifact@v4
with:
name: privacy_guides.zim
path: privacy_guides.zim

release:
name: Create release notes
needs: build
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/download-artifact@v4
with:
name: offline.tar.gz

- uses: actions/download-artifact@v4
with:
name: offline.zip

- uses: actions/download-artifact@v4
with:
name: privacy_guides.zim

- name: Create release notes
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
token: ${{ secrets.REPO_TOKEN }}
artifacts: "offline.zip,offline.tar.gz,privacy_guides.zim"
name: offline-privacy_guides.zim
path: offline-privacy_guides.zim
67 changes: 41 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,75 +30,90 @@ on:
required: true
type: string
lang:
required: true
type: string
i18n:
required: true
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.i18n }}
continue-on-error: ${{ inputs.continue-on-error }}
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repo }}
ref: ${{ inputs.ref }}
persist-credentials: 'false'

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

- run: |
rmdir modules/mkdocs-material
mv modules/mkdocs-material-insiders modules/mkdocs-material
mv modules/repo-mkdocs-material-insiders modules/mkdocs-material
rmdir theme/assets/brand
mv modules/brand theme/assets/brand
mv modules/repo-brand theme/assets/brand
- if: inputs.i18n
- if: inputs.lang != 'en'
run: |
cp -rl modules/i18n/i18n .
cp -rl modules/i18n/includes .
cp -rl modules/i18n/theme .
cp -rl modules/repo-i18n/i18n .
cp -rl modules/repo-i18n/includes .
cp -rl modules/repo-i18n/theme .
- name: Python setup
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
python-version: '3.8'
cache: 'pipenv'

- name: Cache files
uses: actions/cache@v4.0.2
- uses: actions/cache/restore@v4.0.2
with:
key: ${{ inputs.ref }}
key: site-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-${{ hashfiles('.cache/**') }}
path: .cache
restore-keys: |
site-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-
site-cache-${{ inputs.repo }}-${{ inputs.lang }}-
site-cache-${{ github.repository }}-${{ inputs.lang }}
- name: Install Python dependencies
run: |
- run: |
pip install pipenv
pipenv install
sudo apt install pngquant
- name: Build website
env:
- if: inputs.lang != 'en'
uses: falti/dotenv-action@v1.1
with:
path: includes/strings.${{ inputs.lang }}.env
export-variables: true

- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARDS: false
CONTEXT: deploy-preview
NETLIFY: true
CONTEXT: ${{ inputs.context }}
PRODUCTION: true
run: |
pipenv run mkdocs build --config-file config/mkdocs.${{ inputs.lang }}.yml
cp -r static/* site/
pipenv run mkdocs --version
tar -czvf site-build-${{ inputs.lang }}.tar.gz site
- name: Upload tar.gz file
uses: actions/upload-artifact@v4
- uses: actions/cache/save@v4.0.2
with:
key: site-cache-${{ inputs.repo }}-${{ inputs.lang }}-${{ inputs.ref }}-${{ hashfiles('.cache/**') }}
path: .cache

- uses: actions/upload-artifact@v4
with:
name: site-build-${{ inputs.lang }}.tar.gz
path: site-build-${{ inputs.lang }}.tar.gz
20 changes: 2 additions & 18 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,10 @@ on:
workflow_call:

jobs:
brand:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: brand
failOnError: false

i18n:
runs-on: ubuntu-latest
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: i18n
failOnError: false

mkdocs-material-insiders:
runs-on: ubuntu-latest
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: mkdocs-material-insiders
name: repo-*
failOnError: false

0 comments on commit 353955f

Please sign in to comment.