Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: finalize automation/CI workflows #34

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,35 @@ concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

# This job requires deploy keys to be added to target repositories (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys)
# Generate deploy keys locally:
# $ ssh-keygen -t rsa -f awesome-selfhosted-deploy-key -C awesome-selfhosted-deploy-key
# $ ssh-keygen -t rsa -f awesome-selfhosted-html-deploy-key -C awesome-selfhosted-html-deploy-key
# Paste the contents of awesome-selfhosted-deploy-key.pub to https://github.com/nodiscc/awesome-selfhosted/settings/keys/new, name: awesome-selfhosted-deploy-key, allow write access
# Paste the contents of awesome-selfhosted-html-deploy-key.pub to https://github.com/nodiscc/awesome-selfhosted-html-preview/settings/keys/new, name: awesome-selfhosted-html-deploy-key
# Access https://github.com/awesome-selfhosted/awesome-selfhosted-data/settings/environments, create new environment with name: production
# - deployment branches: selected branches
# - add deployment branch rule: branch name pattern: master
# - environment secrets: add secret with name: SSH_MARKDOWN_DEPLOY_KEY, and value: paste the contents of awesome-selfhosted-deploy-key
# - environment secrets: add secret with name: SSH_HTML_DEPLOY_KEY, and value: paste the contents of awesome-selfhosted-html-deploy-key

jobs:
build:
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make awesome_lint
- run: make export
- run: make export_markdown export_html
- name: setup markdown repository SSH deploy key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_MARKDOWN_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 0600 ~/.ssh/id_rsa
- run: make push_markdown
- name: setup HTML repository SSH deploy key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_HTML_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 0600 ~/.ssh/id_rsa
- run: make push_html
2 changes: 1 addition & 1 deletion .github/workflows/daily-checks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dead links and unmaintained projects checks
name: dead links/unmaintained projects checks

on:
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: make awesome_lint
- run: make export
- run: make export_markdown
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
awesome-selfhosted/
awesome-selfhosted-html-preview/
html/
.venv/
12 changes: 6 additions & 6 deletions .hecat/export.yml → .hecat/export-html.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
steps:
- name: export YAML data to awesome-selfhosted markdown
module: exporters/markdown_singlepage
- name: export YAML data to multi-page markdown site
module: exporters/markdown_multipage
module_options:
source_directory: ./
output_directory: awesome-selfhosted
output_file: README.md
back_to_top_url: '#awesome-selfhosted'
# authors_file: AUTHORS.md
output_directory: html
exclude_licenses:
- '⊘ Proprietary'
- 'BUSL-1.1'
Expand All @@ -16,3 +13,6 @@ steps:
- 'Commons-Clause'
- 'DPL'
- 'SSPL-1.0'
- 'DPL'
- 'Elastic-1.0'
- 'Elastic-2.0'
46 changes: 46 additions & 0 deletions .hecat/export-markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
steps:
- name: export YAML data to single-page markdown
module: exporters/markdown_singlepage
module_options:
source_directory: ./
output_directory: awesome-selfhosted
output_file: README.md
markdown_header: markdown/header.md
markdown_footer: markdown/footer.md
back_to_top_url: '#awesome-selfhosted'
exclude_licenses:
- '⊘ Proprietary'
- 'BUSL-1.1'
- 'CC-BY-NC-4.0'
- 'CC-BY-NC-SA-3.0'
- 'CC-BY-ND-3.0'
- 'Commons-Clause'
- 'DPL'
- 'SSPL-1.0'
- 'DPL'
- 'Elastic-1.0'
- 'Elastic-2.0'

- name: export YAML data to single-page markdown (non-free)
module: exporters/markdown_singlepage
module_options:
source_directory: ./
output_directory: awesome-selfhosted
output_file: non-free.md
markdown_header: markdown/non-free-header.md
licenses_file: licenses-nonfree.yml
back_to_top_url: '##awesome-selfhosted---non-free-software'
render_empty_categories: False
render_category_headers: False
include_licenses:
- '⊘ Proprietary'
- 'BUSL-1.1'
- 'CC-BY-NC-4.0'
- 'CC-BY-NC-SA-3.0'
- 'CC-BY-ND-3.0'
- 'Commons-Clause'
- 'DPL'
- 'SSPL-1.0'
- 'DPL'
- 'Elastic-1.0'
- 'Elastic-2.0'
47 changes: 37 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# requirements: git bash make python3-pip python3-venv
SHELL := /bin/bash
MARKDOWN_REPOSITORY = nodiscc/awesome-selfhosted
HTML_REPOSITORY = nodiscc/awesome-selfhosted-html-preview

.PHONY: install # install build tools in a virtualenv
install:
python3 -m venv .venv
source .venv/bin/activate && \
pip3 install wheel && \
pip3 install --force git+https://github.com/nodiscc/hecat.git@master
pip3 install --force git+https://github.com/nodiscc/hecat.git@master 'sphinx<7'

.PHONY: import # import data from original list at https://github.com/awesome-selfhosted/awesome-selfhosted
import: install
rm -rf awesome-selfhosted && git clone --depth=1 https://github.com/awesome-selfhosted/awesome-selfhosted
import: clean install
git clone --depth=1 https://github.com/awesome-selfhosted/awesome-selfhosted
cp awesome-selfhosted/.github/.mailmap .mailmap
cp awesome-selfhosted/AUTHORS AUTHORS
rm -rf tags/ software/ platforms/
Expand All @@ -27,13 +30,37 @@ awesome_lint: install
source .venv/bin/activate && \
hecat --config .hecat/awesome-lint.yml

.PHONY: export # export markdown singlepage document from yaml data
export: install
rm -rf awesome-selfhosted && git clone https://github.com/awesome-selfhosted/awesome-selfhosted
source .venv/bin/activate && \
hecat --config .hecat/export.yml
.PHONY: export_markdown # render markdown export from YAML data (https://github.com/awesome-selfhosted/awesome-selfhosted)
export_markdown: install
rm -rf awesome-selfhosted/
git clone https://github.com/$(MARKDOWN_REPOSITORY)
source .venv/bin/activate && hecat --config .hecat/export-markdown.yml
cd awesome-selfhosted && git diff --color=always

.PHONY: export_html # render HTML export from YAML data (https://nodiscc.github.io/awesome-selfhosted-html-preview/)
export_html: install
rm -rf awesome-selfhosted-html-preview/ html/
git clone https://github.com/$(HTML_REPOSITORY)
mkdir html && source .venv/bin/activate && hecat --config .hecat/export-html.yml
sed -i 's|<a href="https://github.com/pradyunsg/furo">Furo</a>|<a href="https://github.com/nodiscc/hecat/">hecat</a>, <a href="https://www.sphinx-doc.org/">sphinx</a> and <a href="https://github.com/pradyunsg/furo">furo</a>. Content under <a href="https://github.com/awesome-selfhosted/awesome-selfhosted-data/blob/master/LICENSE">CC-BY-SA 3.0</a> license.|' .venv/lib/python*/site-packages/furo/theme/furo/page.html
source .venv/bin/activate && sphinx-build -b html -c ./ html/md/ html/html/
rm -rf html/html/.buildinfo html/html/objects.inv html/html/.doctrees awesome-selfhosted-html-preview/*

.PHONY: push_markdown # commit and push changes to the markdown repository
push_markdown:
cd awesome-selfhosted && git remote set-url origin [email protected]:$(MARKDOWN_REPOSITORY)
cd awesome-selfhosted && git config user.name awesome-selfhosted-bot && git config user.email [email protected]
cd awesome-selfhosted && git add . && (git diff-index --quiet HEAD || git commit -m "[bot] build markdown repository")
cd awesome-selfhosted && git push -f

.PHONY: push_html # commit and push changes to the HTML site repository (amend previous commit and force-push)
push_html:
mv html/html/* awesome-selfhosted-html-preview/
cd awesome-selfhosted-html-preview/ && git remote set-url origin [email protected]:$(HTML_REPOSITORY)
cd awesome-selfhosted-html-preview/ && git config user.name awesome-selfhosted-bot && git config user.email [email protected]
cd awesome-selfhosted-html-preview/ && git add . && (git diff-index --quiet HEAD || git commit --amend -m "[bot] build HTML site")
cd awesome-selfhosted-html-preview/ && git push -f

.PHONY: url_check # check URLs for dead links or other connection problems
url_check: install
source .venv/bin/activate && \
Expand All @@ -42,11 +69,11 @@ url_check: install
.PHONY: authors # update the AUTHORS file
authors:
printf "Commits|Author\n-------|---------------------------------------------------\n" > AUTHORS
git shortlog -sne >> AUTHORS
git shortlog -sne | grep -v awesome-selfhosted-bot >> AUTHORS

.PHONY: clean # clean files generated by automated tasks
clean:
rm -rf awesome-selfhosted
rm -rf awesome-selfhosted/ awesome-selfhosted-html-preview/ html/

.PHONY: help # generate list of targets with descriptions
help:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ install install build tools in a virtualenv
import import data from original list at https://github.com/awesome-selfhosted/awesome-selfhosted
update_metadata update metadata from project repositories/API
awesome_lint check data against awesome-selfhosted guidelines
export export markdown singlepage document from yaml data
export_markdown render markdown export from YAML data (https://github.com/awesome-selfhosted/awesome-selfhosted)
export_html render HTML export from YAML data (https://nodiscc.github.io/awesome-selfhosted-html-preview/)
push_markdown commit and push changes to the markdown repository
push_html commit and push changes to the HTML site repository (amend previous commit and force-push)
url_check check URLs for dead links or other connection problems
authors update the AUTHORS file
clean clean files generated by automated tasks
Expand Down
49 changes: 49 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Configuration file for the Sphinx documentation builder.
# https://www.sphinx-doc.org/en/master/usage/configuration.html
project = 'awesome-selfhosted'
author = 'awesome-selfhosted community'
version = '1.0.0'
release = '1.0.0'
copyright = '2015-2023, the awesome-selfhosted community'
language = 'en'
html_title = 'awesome-selfhosted'
html_theme = 'furo'
html_show_sphinx = False
html_show_search_summary = True
html_copy_source = False
html_show_copyright = True
html_use_opensearch = 'https://nodiscc.github.io/awesome-selfhosted-html-preview/'
html_favicon = '_static/favicon.ico'
html_logo = '_static/logo.svg'
extensions = ['myst_parser', 'sphinx_design']
source_suffix = ['.md']
templates_path = ['_templates']
exclude_patterns = []
html_static_path = ['_static']

# myst-parser configuration (https://myst-parser.readthedocs.io/en/latest/configuration.html)
myst_enable_extensions = ['fieldlist']
myst_html_meta = {
"description lang=en": "A list of Free Software network services and web applications which can be hosted on your own servers",
"charset": "UTF-8"
}

# theme configuration (https://pradyunsg.me/furo/customisation/)
html_theme_options = {
"top_of_page_button": None,
# "announcement": "Example announcement!"
"source_repository": "https://github.com/awesome-selfhosted/awesome-selfhosted-data",
"source_branch": "master",
"footer_icons": [
{
"name": "GitHub",
"url": "https://github.com/awesome-selfhosted/awesome-selfhosted-data",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
"class": "",
},
]
}
2 changes: 1 addition & 1 deletion markdown/header.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Awesome-Selfhosted

[![Awesome](_static/awesome.png)](https://github.com/sindresorhus/awesome) [![](https://github.com/awesome-selfhosted/awesome-selfhosted-data/actions/workflows/ci.yml/badge.svg)](https://github.com/awesome-selfhosted/awesome-selfhosted/issues/3558)
[![Awesome](_static/awesome.png)](https://github.com/sindresorhus/awesome) [![](https://github.com/awesome-selfhosted/awesome-selfhosted-data/actions/workflows/daily-checks.yml/badge.svg)](https://github.com/awesome-selfhosted/awesome-selfhosted/issues/3558)

Self-hosting is the practice of hosting and managing applications on your own server(s) instead of consuming from [SaaSS](https://www.gnu.org/philosophy/who-does-that-server-really-serve.html) providers.

Expand Down