Skip to content

Commit

Permalink
Adding Sphinx to the repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
mehaase committed May 7, 2024
1 parent e124123 commit bfd9d65
Show file tree
Hide file tree
Showing 16 changed files with 1,864 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/delete-web-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Delete Preview Build

on:
pull_request:
types: [closed]

permissions:
contents: read
id-token: write
pages: write
pull-requests: write

jobs:
azure_blob:
runs-on: ubuntu-latest
env:
AZURE_STORAGE_ACCOUNT: {{ cookiecutter.storage_account }}
AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Install Azure CLI
run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Delete old blobs
run: az storage blob delete-batch -s '$web' --pattern "$BRANCH_NAME/*"
120 changes: 120 additions & 0 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build Sphinx Docs

on:
push:
branches: [main]
pull_request:

permissions:
contents: read
pages: write
id-token: write
pull-requests: write

# If another web build starts for the same branch, cancel the previous build. This
# protects us from two builds trying to upload at the same time and clobbering each
# other.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org/ | python -
- name: Add Poetry to PATH
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install
- name: Build HTML docs
run: poetry run make docs-ci
- name: Upload HTML docs
uses: actions/upload-artifact@v3
with:
name: threat-modeling-with-attack-docs-html
path: docs/_build/dirhtml/

# Delete this job before public release and clear GitHub secrets:
azure_blob:
needs: docs
runs-on: ubuntu-latest
env:
AZURE_STORAGE_ACCOUNT: ctidthreatmodeling
AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
STATICRYPT_PASS: ${{ secrets.STATICRYPT_PASS }}
NODE_OPTIONS: --max-old-space-size=8192
steps:
- uses: actions/setup-node@v3
with:
node-version: '19'
- run: npm install -g staticrypt
- name: Download HTML docs
uses: actions/download-artifact@v3
with:
name: threat-modeling-with-attack-docs-html
path: docs
- run: >
staticrypt --remember 30 --salt b530e4408fd941209e53e4786421f837 \
--password $STATICRYPT_PASS --short \
--template-title "Threat Modeling with ATT&CK (branch: $BRANCH_NAME)" \
--template-instructions "The contents of this site are marked TLP:AMBER:CTID-R&D:23-83. Do not share with unauthorized individuals." \
--template-color-primary "#6241c5" \
--template-color-secondary "#b2b2b2" \
--template-button "Log In" \
-r docs/
- name: Ensure StatiCrypt ran # StatiCrypt will fail without warning; verify it created a directory
run: test -d encrypted
- name: Copy encrypted HTML files
run: rsync -Ir -v --include='*.html' --exclude='*.*' encrypted/docs .
- name: Set the branch name
run: mv docs "$BRANCH_NAME"
- name: Install Azure CLI
run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Delete old blobs
run: az storage blob delete-batch -s '$web' --pattern "$BRANCH_NAME/*"
- name: Upload to blob storage
run: az storage blob upload-batch -s . --pattern "$BRANCH_NAME/*" -d '$web'
- uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `This PR has been published to https://${process.env['AZURE_STORAGE_ACCOUNT']}.z13.web.core.windows.net/${process.env['BRANCH_NAME']}/`,
})
# # TODO Uncomment before publishing repository.
# github_pages:
# # This job only runs when committing or merging to main branch.
# if: github.ref_name == 'main'
# needs: docs
# runs-on: ubuntu-latest
# environment:
# name: github-pages
# url: $\{\{ steps.deployment.outputs.page_url \}\}

# steps:
# - name: Setup Pages
# uses: actions/configure-pages@v2
# - name: Download HTML docs
# uses: actions/download-artifact@v3
# with:
# name: threat-modeling-with-attack-docs-html
# path: docs
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v1
# with:
# path: ./docs
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v1
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.exclude": {
"**/__pycache__": true
},
"editor.rulers": [
88
],
"python.formatting.autopep8Path": "black",
"markdown.extension.toc.levels": "2..6",
"python.formatting.provider": "black",
"editor.formatOnSave": true
}
Binary file added docs/.DS_Store
Binary file not shown.
Loading

0 comments on commit bfd9d65

Please sign in to comment.