Skip to content

Commit

Permalink
WIP use variables to identify target repos, fix SSH key generation/au…
Browse files Browse the repository at this point in the history
…thorization steps
  • Loading branch information
nodiscc committed Jul 24, 2023
1 parent 9954b19 commit da4d3fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
# 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_DEPLOY_KEY, and value: paste the contents of awesome-selfhosted-deploy-key
# - 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:
Expand All @@ -27,13 +27,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# - run: make awesome_lint
- run: make awesome_lint
- run: make export_markdown
- run: make export_html
- name: setup markdown repository SSH deploy key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_DEPLOY_KEY }}" > ~/.ssh/id_rsa
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
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# requirements: git bash make python3-pip python3-venv
SHELL := /bin/bash
MARKDOWN_REPOSITORY = awesome-selfhosted/awesome-selfhosted
HTML_REPOSITORY = nodiscc/awesome-selfhosted-html-preview

.PHONY: install # install build tools in a virtualenv
install:
Expand Down Expand Up @@ -31,30 +33,30 @@ awesome_lint: install
.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/nodiscc/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/nodiscc/awesome-selfhosted-html-preview
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]:nodiscc/awesome-selfhosted
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]:nodiscc/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
Expand Down

0 comments on commit da4d3fc

Please sign in to comment.