Last active
February 19, 2025 15:27
-
-
Save noflcl/901d81d6ddd0f7869a65d1717c51fb98 to your computer and use it in GitHub Desktop.
Builds and pushes signed commits - base image is Ubuntu 22.04 for build env
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Forgejo local runner building mkdocs and deploying to pages | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| paths: | |
| - 'mkdocs.yaml' | |
| - 'docs/*' | |
| - 'README.md' | |
| - '.forgejo/workflows/mkdocs.yaml' | |
| jobs: | |
| mkdocs: | |
| runs-on: docker | |
| steps: | |
| - name: Setup SSH keys and configs | |
| run: | | |
| if [ ! -d ~/.ssh ]; then | |
| mkdir ~/.ssh | |
| fi | |
| echo "${{ secrets.ssh_config }}" > ~/.ssh/config | |
| ssh-keyscan codeberg.org >> ~/.ssh/known_hosts | |
| echo "${{ secrets.PRIV_AUTOBOT }}" > ~/.ssh/autobot | |
| echo "${{ secrets.PUB_AUTOBOT }}" > ~/.ssh/autobot.pub | |
| chmod 700 ~/.ssh/ | |
| chmod 600 ~/.ssh/* | |
| chmod 644 -f ~/.ssh/*.pub ~/.ssh/config ~/.ssh/known_hosts | |
| ssh -vvv -i ~/.ssh/autobot -T git@codeberg.org | |
| - name: Configure git and clone repos | |
| run: | | |
| git config --global user.email noflcl@noreply.codeberg.org | |
| git config --global user.name noflcl | |
| git config --global commit.gpgsign true | |
| git config --global gpg.format ssh | |
| git config --global user.signingkey ~/.ssh/autobot.pub | |
| git clone git@codeberg.org:noflcl/mkdocs.git | |
| git clone git@codeberg.org:noflcl/pages.git | |
| - name: Updating the base image and installing dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y python3 python3-pip | |
| - name: Installing mkdocs requirements and building a new static site | |
| run: | | |
| cd mkdocs | |
| pip install -U -r ./requirements.txt | |
| mkdocs build | |
| - name: Check and commit any changes to the Codeberg pages repository | |
| run: | | |
| cd mkdocs | |
| echo -e "\nMoving site to pages repository..." | |
| cp -r site/* ../pages/ | |
| cd ../pages | |
| if [[ -z $(git status -u --porcelain) ]]; then | |
| echo "no changes found, proceeding" | |
| else | |
| git add . | |
| git commit -m "This site is published with a local forgejo-runner π€" --author="autobot <autobot@noreply>" | |
| git push | |
| fi | |
| - name: Job has completed | |
| run: | | |
| echo π₯³ You built mkdocs and deployed it π π |
Author
Author
Got singed commits from forgejo runnert, using a separate author so I know what I pushed and what the bot pushes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Final step I'd like to do is break up this giant "run: | " block into proper named sections. But it works, it builds mkdocs and moves the site into a codeberg pages repo and pushes changes.