|
| 1 | +# Deploy Tracee documentation: |
| 2 | +# - on docs changes in main branch -> deploy dev docs |
| 3 | +# - on manual trigger -> deploy either dev or latest docs |
| 4 | + |
| 5 | +name: Deploy documentation |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + target: |
| 10 | + description: Which docs version to deploy |
| 11 | + required: true |
| 12 | + default: dev |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - dev |
| 16 | + - latest |
| 17 | + ref: |
| 18 | + description: Tag/ref to deploy (required for latest, ignored for dev) |
| 19 | + required: false |
| 20 | + |
| 21 | + push: |
| 22 | + paths: |
| 23 | + - "docs/**" |
| 24 | + - mkdocs.yml |
| 25 | + branches: |
| 26 | + - main |
| 27 | + |
| 28 | +permissions: {} |
| 29 | + |
| 30 | +jobs: |
| 31 | + deploy: |
| 32 | + name: Deploy documentation |
| 33 | + permissions: |
| 34 | + contents: write |
| 35 | + runs-on: ${{ vars.UBUNTU_X86_RUNNER_LABEL || (github.repository_owner == 'aquasecurity' && 'ubuntu-24.04') }} |
| 36 | + steps: |
| 37 | + - name: Validate latest input |
| 38 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'latest' && github.event.inputs.ref == '' }} |
| 39 | + run: | |
| 40 | + echo "Input 'ref' is required when target=latest (example: v0.0.1)" |
| 41 | + exit 1 |
| 42 | +
|
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 45 | + with: |
| 46 | + ref: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'latest' && github.event.inputs.ref != '') && github.event.inputs.ref || 'main' }} |
| 47 | + fetch-depth: 0 |
| 48 | + persist-credentials: true |
| 49 | + |
| 50 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 51 | + with: |
| 52 | + python-version: 3.12.3 |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + run: | |
| 56 | + pip install git+https://github.com/squidfunk/mkdocs-material.git@6c52ed6289b171a153875491f059a94819ec3e10 # 9.7.6 |
| 57 | + pip install git+https://github.com/jimporter/mike.git@6b876a40892f6d16d984247821d5a3ae85745e36 # v2.1.3 |
| 58 | + pip install git+https://github.com/fralau/mkdocs-macros-plugin.git@b906a368ecfd5cd25abcbea0a37f7a23944a8355 # v1.3.7 |
| 59 | +
|
| 60 | + - name: Setup Git |
| 61 | + run: | |
| 62 | + git config user.name "github-actions" |
| 63 | + git config user.email "github-actions@github.com" |
| 64 | +
|
| 65 | + - name: Deploy docs |
| 66 | + env: |
| 67 | + EVENT_NAME: ${{ github.event_name }} |
| 68 | + TARGET: ${{ github.event.inputs.target }} |
| 69 | + REF: ${{ github.event.inputs.ref }} |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | +
|
| 73 | + if [ "${EVENT_NAME}" = "push" ] || [ "${TARGET}" = "dev" ]; then |
| 74 | + mike deploy --push dev |
| 75 | + elif [ "${TARGET}" = "latest" ]; then |
| 76 | + VERSION="${REF}" |
| 77 | + mike deploy --push --update-aliases ${VERSION%.*} latest |
| 78 | + else |
| 79 | + echo "Unsupported deploy target: '${TARGET}' for event '${EVENT_NAME}'" |
| 80 | + exit 1 |
| 81 | + fi |
0 commit comments