|
| 1 | +name: Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'docs/**' |
| 9 | + - 'mkdocs.yml' |
| 10 | + - 'pyproject.toml' |
| 11 | + - '.github/workflows/docs.yml' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + pages: write |
| 17 | + id-token: write |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + build-and-deploy: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Setup Python |
| 31 | + uses: actions/setup-python@v4 |
| 32 | + with: |
| 33 | + python-version: '3.11' |
| 34 | + |
| 35 | + - name: Install Poetry |
| 36 | + uses: snok/install-poetry@v1 |
| 37 | + with: |
| 38 | + version: latest |
| 39 | + virtualenvs-create: true |
| 40 | + virtualenvs-in-project: true |
| 41 | + |
| 42 | + - name: Load cached dependencies |
| 43 | + uses: actions/cache@v3 |
| 44 | + with: |
| 45 | + path: .venv |
| 46 | + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 47 | + |
| 48 | + - name: Install dependencies |
| 49 | + run: poetry install --no-interaction --no-root |
| 50 | + |
| 51 | + - name: Build documentation |
| 52 | + run: poetry run mkdocs build |
| 53 | + |
| 54 | + - name: Setup Pages |
| 55 | + uses: actions/configure-pages@v3 |
| 56 | + |
| 57 | + - name: Upload artifact |
| 58 | + uses: actions/upload-pages-artifact@v2 |
| 59 | + with: |
| 60 | + path: ./site |
| 61 | + |
| 62 | + - name: Deploy to GitHub Pages |
| 63 | + id: deployment |
| 64 | + uses: actions/deploy-pages@v2 |
| 65 | + |
| 66 | + - name: Send Discord notification |
| 67 | + env: |
| 68 | + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 69 | + run: | |
| 70 | + # Check if webhook URL is set |
| 71 | + if [ -z "$DISCORD_WEBHOOK_URL" ]; then |
| 72 | + echo "Discord webhook URL not set, skipping notification" |
| 73 | + exit 0 |
| 74 | + fi |
| 75 | +
|
| 76 | + # Get commit info |
| 77 | + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") |
| 78 | + COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an") |
| 79 | + COMMIT_SHA=$(git log -1 --pretty=format:"%h") |
| 80 | + COMMIT_URL="https://github.com/${{ github.repository }}/commit/${{ github.sha }}" |
| 81 | +
|
| 82 | + # Create Discord notification |
| 83 | + cat << EOF > discord_payload.json |
| 84 | + { |
| 85 | + "embeds": [ |
| 86 | + { |
| 87 | + "title": "π Documentation Deployed", |
| 88 | + "description": "The Beet documentation has been successfully updated and deployed!", |
| 89 | + "color": 3447003, |
| 90 | + "url": "https://alter-dimensions.github.io/beetween", |
| 91 | + "fields": [ |
| 92 | + { |
| 93 | + "name": "π Latest Commit", |
| 94 | + "value": "**$COMMIT_MESSAGE**\nby $COMMIT_AUTHOR (\`$COMMIT_SHA\`)", |
| 95 | + "inline": false |
| 96 | + }, |
| 97 | + { |
| 98 | + "name": "π Links", |
| 99 | + "value": "[π View Documentation](https://alter-dimensions.github.io/beetween) β’ [π» View Commit]($COMMIT_URL)", |
| 100 | + "inline": false |
| 101 | + } |
| 102 | + ], |
| 103 | + "footer": { |
| 104 | + "text": "Beetween Documentation β’ Pre-commit validated" |
| 105 | + }, |
| 106 | + "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" |
| 107 | + } |
| 108 | + ] |
| 109 | + } |
| 110 | + EOF |
| 111 | +
|
| 112 | + # Send notification |
| 113 | + curl -H "Content-Type: application/json" -d @discord_payload.json "$DISCORD_WEBHOOK_URL" |
0 commit comments