|
1 |
| -name: Publish-and-Render |
| 1 | +name: Update Documentation |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 |
| - pull_request: |
6 |
| - branches: [main] |
| 5 | + branches: [ main ] |
| 6 | + paths: |
| 7 | + - 'index.qmd' |
| 8 | + - '.github/workflows/update-docs.yml' |
7 | 9 | workflow_dispatch:
|
8 | 10 |
|
9 | 11 | jobs:
|
10 |
| - test: |
11 |
| - strategy: |
12 |
| - fail-fast: false |
13 |
| - matrix: |
14 |
| - python-version: ["3.12"] |
15 |
| - poetry-version: [latest] |
16 |
| - os: [ubuntu-latest] |
17 |
| - |
18 |
| - runs-on: ${{ matrix.os }} |
19 |
| - |
20 |
| - services: |
21 |
| - postgres: |
22 |
| - image: postgres:latest |
23 |
| - env: |
24 |
| - POSTGRES_DB: test_db |
25 |
| - POSTGRES_USER: postgres |
26 |
| - POSTGRES_PASSWORD: postgres |
27 |
| - ports: |
28 |
| - - 5432:5432 |
29 |
| - options: >- |
30 |
| - --health-cmd pg_isready |
31 |
| - --health-interval 10s |
32 |
| - --health-timeout 5s |
33 |
| - --health-retries 5 |
34 |
| - |
| 12 | + update-docs: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
35 | 16 | steps:
|
36 |
| - - uses: actions/checkout@v4 |
37 |
| - |
38 |
| - - uses: actions/setup-python@v5 |
| 17 | + - name: Check out repository |
| 18 | + uses: actions/checkout@v4 |
39 | 19 | with:
|
40 |
| - python-version: ${{ matrix.python-version }} |
41 |
| - |
42 |
| - - name: Set env variables for quarto |
43 |
| - run: | |
44 |
| - echo "DB_USER=postgres" >> $GITHUB_ENV |
45 |
| - echo "DB_PASSWORD=postgres" >> $GITHUB_ENV |
46 |
| - echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV |
47 |
| - echo "DB_PORT=5432" >> $GITHUB_ENV |
48 |
| - echo "DB_NAME=test_db" >> $GITHUB_ENV |
49 |
| - echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV |
50 |
| - echo "BASE_URL=http://localhost:8000" >> $GITHUB_ENV |
51 |
| - echo "RESEND_API_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV |
52 |
| - |
53 |
| - - name: Verify environment variables for quarto |
54 |
| - run: | |
55 |
| - echo "Checking if required environment variables are set..." |
56 |
| - [ -n "$DB_USER" ] && \ |
57 |
| - [ -n "$DB_PASSWORD" ] && \ |
58 |
| - [ -n "$DB_HOST" ] && \ |
59 |
| - [ -n "$DB_PORT" ] && \ |
60 |
| - [ -n "$DB_NAME" ] && \ |
61 |
| - [ -n "$SECRET_KEY" ] && \ |
62 |
| - [ -n "$RESEND_API_KEY" ] |
| 20 | + fetch-depth: 0 |
63 | 21 |
|
64 | 22 | - name: Set up Quarto
|
65 | 23 | uses: quarto-dev/quarto-actions/setup@v2
|
66 | 24 |
|
67 |
| - - name: Publish |
68 |
| - uses: quarto-dev/quarto-actions/publish@v2 |
69 |
| - |
70 |
| - - name: Render |
71 |
| - uses: quarto-dev/quarto-actions/render@v2 |
| 25 | + - name: Render Documentation |
| 26 | + run: | |
| 27 | + # Publish Quarto documentation |
| 28 | + quarto publish --no-prompt --no-browser |
| 29 | + |
| 30 | + # Render README in GitHub Flavored Markdown |
| 31 | + quarto render index.qmd --output-dir . --output README.md --to gfm |
| 32 | + |
| 33 | + # Remove index.html if it exists |
| 34 | + rm -f index.html |
| 35 | +
|
| 36 | + - name: Commit and Push Changes |
| 37 | + run: | |
| 38 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 39 | + git config --local user.name "github-actions[bot]" |
| 40 | + |
| 41 | + # Stage only specific files |
| 42 | + git add README.md |
| 43 | + |
| 44 | + # Only commit if there are changes |
| 45 | + git diff --staged --quiet || git commit -m "docs: Update README.md via automated workflow" |
| 46 | + |
| 47 | + # Push changes |
| 48 | + git push |
| 49 | +
|
| 50 | + # Optional step for generating additional documentation files |
| 51 | + - name: Generate Additional Documentation |
| 52 | + if: false # Disabled by default - enable when needed |
| 53 | + run: | |
| 54 | + # Example: Generate .txt version |
| 55 | + quarto render index.qmd --output-dir . --output rules.txt --to plain |
| 56 | + |
| 57 | + # Example: Generate .cursorrules version |
| 58 | + quarto render index.qmd --output-dir . --output rules.cursorrules --to plain |
| 59 | + |
| 60 | + # Commit and push additional files |
| 61 | + git add rules.txt rules.cursorrules |
| 62 | + git diff --staged --quiet || git commit -m "docs: Update additional documentation files" |
| 63 | + git push |
0 commit comments