# SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-03; WEIDNER, Marc S.; # SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/draft-weidner-catalog-rr-ext.git # SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency # SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; # SPDX-FileType: SOURCE # SPDX-License-Identifier: EUPL-1.2 # SPDX-LicenseComment: This file is part of the draft-weidner-catalog-rr-ext framework. # SPDX-PackageName: draft-weidner-catalog-rr-ext # SPDX-Security-Contact: security@coresecret.eu ### Version Master V1.00.128.2025.06.03 name: Render RFCXML to PDF. permissions: contents: write on: push: branches: - master paths: - "**/*.rfc.xml" jobs: render-rfcxml-to-pdf: name: Render RFCXML to PDF. runs-on: ubuntu-latest steps: - name: ⚙️ Preparing SSH Setup, SSH Deploy Key, Known Hosts, .config. shell: bash run: | set -euo pipefail rm -rf ~/.ssh && mkdir -m700 ~/.ssh ### Private Key echo "${{ secrets.SSH_MSW_DEPLOY_CORESECRET_DEV }}" >| ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ### Scan git.coresecret.dev to fill ~/.ssh/known_hosts ssh-keyscan -p 42842 git.coresecret.dev >| ~/.ssh/known_hosts chmod 600 ~/.ssh/known_hosts ### Generate SSH Config for git.coresecret.dev Custom-Port cat <| ~/.ssh/config Host git.coresecret.dev HostName git.coresecret.dev Port 42842 IdentityFile ~/.ssh/id_ed25519 StrictHostKeyChecking yes UserKnownHostsFile ~/.ssh/known_hosts EOF chmod 600 ~/.ssh/config ### https://github.com/actions/checkout/issues/1843 - name: 🛠️ Using manual clone via SSH to circumvent Gitea SHA-256 object issues. shell: bash env: ### GITHUB_REF_NAME contains the branch name from the push event. GITHUB_REF_NAME: ${{ github.ref_name }} run: | set -euo pipefail git clone --branch "${GITHUB_REF_NAME}" ssh://git@git.coresecret.dev:42842/msw/draft-weidner-catalog-rr-ext.git . git fetch --unshallow || echo "Nothing to fetch - already full clone." - name: 🛠️ Cleaning the workspace. shell: bash run: | set -euo pipefail git reset --hard git clean -fd - name: ⚙️ Importing the 'CI PGP DEPLOY ONLY' key. shell: bash run: | set -euo pipefail ### GPG-Home relative to the Runner Workspace to avoid changing global files. export GNUPGHOME="$(pwd)/.gnupg" mkdir -m 700 "${GNUPGHOME}" echo "${{ secrets.PGP_MSW_DEPLOY_CORESECRET_DEV }}" >| ci-bot.sec.asc gpg --batch --import ci-bot.sec.asc ### Trust the key automatically KEY_ID=$(gpg --list-keys --with-colons | awk -F: '/^pub:/ {print $5}') echo "trust-model always" >| "${GNUPGHOME}/gpg.conf" - name: ⚙️ Configuring Git for signed CI/DEPLOY commits. shell: bash run: | set -euo pipefail export GNUPGHOME="$(pwd)/.gnupg" git config user.name "Marc S. Weidner BOT" git config user.email "msw+bot@coresecret.dev" git config commit.gpgsign true git config gpg.program gpg git config gpg.format openpgp - name: ⚙️ Convert APT sources to HTTPS. shell: bash run: | set -euo pipefail sed -i 's|http://\(archive\.ubuntu\.com\|security\.ubuntu\.com\)|https://\1|g' /etc/apt/sources.list sed -i 's|http://\(archive\.ubuntu\.com\|security\.ubuntu\.com\)|https://\1|g' /etc/apt/sources.list.d/*.list || true - name: 🛠️ Install Python, RFC2XML Utilities, Fonts, Libraries. run: | sudo apt-get update sudo apt-get install -y python3-pip libxml2-utils sudo apt-get install -y libpango-1.0-0 libcairo2 libgdk-pixbuf2.0-0 libffi-dev libfontconfig1 fonts-noto fonts-roboto wget unzip - name: 🛠️ Install Python "xml2rfc" and "xml2rfc[pdf]" run: | pip3 install xml2rfc --break-system-packages pip3 install "xml2rfc[pdf]" --break-system-packages - name: 🛠️ Convert all RFCXML to PDF. run: | find . -name "*.rfc.xml" | while read file; do out="${file%.rfc.xml}.pdf" xml2rfc "${file}" --pdf -o "${out}" done - name: 🔄 Sync with remote before commit using merge strategy. shell: bash env: GIT_SSH_COMMAND: "ssh -p 42842" run: | set -euo pipefail export GNUPGHOME="$(pwd)/.gnupg" echo "🔄 Fetching origin/master ..." git fetch origin master echo "🔁 Merging origin/master into current branch ..." git merge --no-edit origin/master || echo "✔️ Already up to date or fast-forward." echo "📋 Post-merge status :" git status git log --oneline -n 5 - name: 📦 Stage generated files. shell: bash env: GIT_SSH_COMMAND: "ssh -p 42842" run: | set -euo pipefail git add *.pdf || echo "✔️ Nothing to add." - name: 🔑 Commit and sign changes with CI metadata. shell: bash env: GIT_SSH_COMMAND: "ssh -p 42842" run: | set -euo pipefail export GNUPGHOME="$(pwd)/.gnupg" if git diff --cached --quiet; then echo "✔️ No staged changes to commit." else echo "📝 Committing changes with GPG signature ..." ### CI Metadata TIMESTAMP_UTC="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" HOSTNAME="$(hostname -f || hostname)" GIT_SHA="$(git rev-parse --short HEAD)" GIT_REF="$(git symbolic-ref --short HEAD || echo detached)" WORKFLOW_ID="${GITHUB_WORKFLOW:-render-md-to-html.yaml}" CI_HEADER="X-CI-Metadata: ${GIT_REF}@${GIT_SHA} at ${TIMESTAMP_UTC} on ${HOSTNAME}" COMMIT_MSG="DEPLOY BOT: Auto-Generate PDFs from *.rfc.xml. [skip ci] ${CI_HEADER} Generated at: ${TIMESTAMP_UTC} Runner Host : ${HOSTNAME} Workflow ID : ${WORKFLOW_ID} Git Commit : ${GIT_SHA} HEAD → ${GIT_REF} " echo "🔏 Commit message :" echo "${COMMIT_MSG}" git commit -S -m "${COMMIT_MSG}" fi - name: 🔁 Push back to repository. shell: bash env: GIT_SSH_COMMAND: "ssh -p 42842" run: | set -euo pipefail echo "📤 Pushing changes to ${GITHUB_REF_NAME} ..." git push origin HEAD:${GITHUB_REF_NAME} # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=yaml