Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Workflow file for this run

name: RFCs
on:
push:
paths:
- 'docs/rfc/**'
- '.github/workflows/rfc.yml'
permissions:
contents: read
jobs:
htmlize:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Checkout full upstream repo
run: |
git remote set-url origin https:/intel/dffml
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
git config --global user.email "[email protected]"
git config --global user.name "DFFML CI/CD"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache
id: pip-cache
run: |
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
- name: pip cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
set -x
python -m pip install -U setuptools pip wheel
python -m pip install "https:/ietf-tools/rfc2html/archive/refs/heads/main.zip#egg=rfc2html"
- name: Make HTML RFCs
shell: python -u {0}
run: |
import rfc2html
for path in pathlib.Path("docs", "rfc").glob("*.txt"):
print("Writing", path)
path.with_suffix(".html").write_text(
rfc2html.markup(path.read_text())
)
- name: Copy git repo
env:
SSH_DFFML_GH_PAGES: ${{ secrets.SSH_DFFML_GH_PAGES }}
run: |
set -x
TEMP_DIRS=()
function cleanup_temp_dirs() {
if [ "x${NO_RM_TEMP}" != "x" ]; then
return
fi
for temp_dir in ${TEMP_DIRS[@]}; do
rm -rf "${temp_dir}"
done
}
# Clean up temporary directories on exit
trap cleanup_temp_dirs EXIT
release_docs="$(mktemp -d)"
TEMP_DIRS+=("${release_docs}")
git clone https:/intel/dffml -b gh-pages \
"${release_docs}/gh-pages-branch"
rm -rf "${release_docs}/gh-pages-branch/rfcs"
cp -r docs/rfcs "${release_docs}/gh-pages-branch"
cd "${release_docs}/gh-pages-branch"
git config user.name 'Alice'
git config user.email '[email protected]'
git add -A
git commit -sam "docs: rfc: $(date)"
ssh_key_dir="$(mktemp -d)"
TEMP_DIRS+=("${ssh_key_dir}")
mkdir -p ~/.ssh
chmod 700 ~/.ssh
python -c "import pathlib, base64, os; keyfile = pathlib.Path(\"${ssh_key_dir}/github\").absolute(); keyfile.write_bytes(b''); keyfile.chmod(0o600); keyfile.write_bytes(base64.b32decode(os.environ['SSH_DFFML_GH_PAGES']))"
ssh-keygen -y -f "${ssh_key_dir}/github" > "${ssh_key_dir}/github.pub"
export GIT_SSH_COMMAND="${GIT_SSH_COMMAND} -o IdentityFile=${ssh_key_dir}/github"
git remote set-url origin [email protected]:intel/dffml
git push -f