|
| 1 | +name: LoTL Update and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "lotl/**" |
| 8 | + - "tools/lotl/**" |
| 9 | + - "requirements-dev.txt" |
| 10 | + - ".github/workflows/lotl-update.yml" |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + ref: |
| 14 | + description: "Git ref to run (branch, tag, or SHA)" |
| 15 | + required: false |
| 16 | + default: "main" |
| 17 | + publish: |
| 18 | + description: "Publish artifacts to gh-pages" |
| 19 | + required: true |
| 20 | + type: boolean |
| 21 | + default: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: write |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: lotl-update-main |
| 28 | + cancel-in-progress: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + lotl-test-gate: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }} |
| 38 | + |
| 39 | + - name: Set up Python |
| 40 | + uses: actions/setup-python@v5 |
| 41 | + with: |
| 42 | + python-version: "3.10" |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: | |
| 46 | + python -m pip install --upgrade pip |
| 47 | + pip install -r requirements-dev.txt |
| 48 | +
|
| 49 | + - name: Validate TL entries (schema and semantic checks) |
| 50 | + run: | |
| 51 | + python -m tools.lotl --validate-only --tl-entries-dir lotl/tl_entries/ |
| 52 | +
|
| 53 | + - name: Run LoTL tests (includes schema validation paths) |
| 54 | + run: | |
| 55 | + pytest tools/lotl/tests/ -v --cov=tools.lotl --cov-report=term-missing --cov-fail-under=90 |
| 56 | +
|
| 57 | + build-and-publish: |
| 58 | + needs: lotl-test-gate |
| 59 | + runs-on: ubuntu-latest |
| 60 | + env: |
| 61 | + LOTL_SIGNING_KEY: ${{ secrets.LOTL_SIGNING_KEY }} |
| 62 | + LOTL_SIGNING_CERT: ${{ secrets.LOTL_SIGNING_CERT }} |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Validate signing secrets are configured |
| 69 | + run: | |
| 70 | + if [ -z "${LOTL_SIGNING_KEY}" ] || [ -z "${LOTL_SIGNING_CERT}" ]; then |
| 71 | + echo "LOTL_SIGNING_KEY and LOTL_SIGNING_CERT secrets must be configured." |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Set up Python |
| 76 | + uses: actions/setup-python@v5 |
| 77 | + with: |
| 78 | + python-version: "3.10" |
| 79 | + |
| 80 | + - name: Install dependencies |
| 81 | + run: | |
| 82 | + python -m pip install --upgrade pip |
| 83 | + pip install -r requirements-dev.txt |
| 84 | +
|
| 85 | + - name: Produce signed LoTL artifacts |
| 86 | + run: | |
| 87 | + python -m tools.lotl --tl-entries-dir lotl/tl_entries/ --output-dir lotl/ |
| 88 | +
|
| 89 | + - name: Prepare gh-pages content |
| 90 | + run: | |
| 91 | + rm -rf .gh-pages-dist |
| 92 | + mkdir -p .gh-pages-dist/assets |
| 93 | + cp lotl/pages/index.html .gh-pages-dist/index.html |
| 94 | + cp lotl/list_of_trusted_lists.json .gh-pages-dist/list_of_trusted_lists.json |
| 95 | + cp lotl/list_of_trusted_lists.xml .gh-pages-dist/list_of_trusted_lists.xml |
| 96 | + cp -r lotl/pages/assets/. .gh-pages-dist/assets/ |
| 97 | +
|
| 98 | + - name: Publish to gh-pages |
| 99 | + if: ${{ github.event_name != 'workflow_dispatch' || inputs.publish }} |
| 100 | + uses: peaceiris/actions-gh-pages@v4 |
| 101 | + with: |
| 102 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + publish_branch: gh-pages |
| 104 | + publish_dir: .gh-pages-dist |
| 105 | + keep_files: true |
0 commit comments