|
| 1 | +name: RFCs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'docs/rfc/**' |
| 7 | + - '.github/workflows/' |
| 8 | + |
| 9 | +jobs: |
| 10 | + htmlize: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + python-version: [3.7] |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + - name: Checkout full upstream repo |
| 19 | + run: | |
| 20 | + git remote set-url origin https://github.com/intel/dffml |
| 21 | + git fetch --prune --unshallow |
| 22 | + git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 23 | + git config --global user.email "[email protected]" |
| 24 | + git config --global user.name "DFFML CI/CD" |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v2 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + - name: Get pip cache |
| 30 | + id: pip-cache |
| 31 | + run: | |
| 32 | + python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)" |
| 33 | + - name: pip cache |
| 34 | + uses: actions/cache@v1 |
| 35 | + with: |
| 36 | + path: ${{ steps.pip-cache.outputs.dir }} |
| 37 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-pip- |
| 40 | + - name: Install dependencies |
| 41 | + run: | |
| 42 | + set -x |
| 43 | + python -m pip install -U setuptools pip wheel |
| 44 | + python -m pip install "https://github.com/ietf-tools/rfc2html/archive/refs/heads/main.zip#egg=rfc2html" |
| 45 | + - name: Make HTML RFCs |
| 46 | + shell: python -u {0} |
| 47 | + run: | |
| 48 | + import rfc2html |
| 49 | +
|
| 50 | + for path in pathlib.Path("docs", "rfc").glob("*.txt"): |
| 51 | + print("Writing", path) |
| 52 | + path.with_suffix(".html").write_text( |
| 53 | + rfc2html.markup(path.read_text()) |
| 54 | + ) |
| 55 | + - name: Copy git repo |
| 56 | + env: |
| 57 | + SSH_DFFML_GH_PAGES: ${{ secrets.SSH_DFFML_GH_PAGES }} |
| 58 | + run: | |
| 59 | + set -x |
| 60 | +
|
| 61 | + TEMP_DIRS=() |
| 62 | +
|
| 63 | + function cleanup_temp_dirs() { |
| 64 | + if [ "x${NO_RM_TEMP}" != "x" ]; then |
| 65 | + return |
| 66 | + fi |
| 67 | + for temp_dir in ${TEMP_DIRS[@]}; do |
| 68 | + rm -rf "${temp_dir}" |
| 69 | + done |
| 70 | + } |
| 71 | +
|
| 72 | + # Clean up temporary directories on exit |
| 73 | + trap cleanup_temp_dirs EXIT |
| 74 | +
|
| 75 | + release_docs="$(mktemp -d)" |
| 76 | + TEMP_DIRS+=("${release_docs}") |
| 77 | +
|
| 78 | + git clone https://github.com/intel/dffml -b gh-pages \ |
| 79 | + "${release_docs}/gh-pages-branch" |
| 80 | + |
| 81 | + rm -rf "${release_docs}/gh-pages-branch/rfcs" |
| 82 | + cp -r docs/rfcs "${release_docs}/gh-pages-branch" |
| 83 | + |
| 84 | + cd "${release_docs}/gh-pages-branch" |
| 85 | + |
| 86 | + git config user.name 'Alice' |
| 87 | + git config user.email '[email protected]' |
| 88 | + |
| 89 | + git add -A |
| 90 | + git commit -sam "docs: rfc: $(date)" |
| 91 | + |
| 92 | + ssh_key_dir="$(mktemp -d)" |
| 93 | + TEMP_DIRS+=("${ssh_key_dir}") |
| 94 | + mkdir -p ~/.ssh |
| 95 | + chmod 700 ~/.ssh |
| 96 | + 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']))" |
| 97 | + ssh-keygen -y -f "${ssh_key_dir}/github" > "${ssh_key_dir}/github.pub" |
| 98 | + export GIT_SSH_COMMAND="${GIT_SSH_COMMAND} -o IdentityFile=${ssh_key_dir}/github" |
| 99 | + |
| 100 | + git remote set-url origin [email protected]:intel/dffml |
| 101 | + git push -f |
0 commit comments