|
| 1 | +# Workflow for deploying Sphinx documentation built within a Docker container to GitHub Pages |
| 2 | +name: Deploy Sphinx Document to Pages |
| 3 | + |
| 4 | +on: |
| 5 | + # Runs on pushes targeting the default branch |
| 6 | + push: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +# Set permissions for the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + pages: write |
| 16 | + id-token: write |
| 17 | + |
| 18 | +# Allow only one concurrent deployment, skipping queued runs, but do not cancel in-progress ones |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Single deploy job since we're just deploying |
| 25 | + deploy: |
| 26 | + environment: |
| 27 | + name: github-pages |
| 28 | + url: ${{ steps.deployment.outputs.page_url }} |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + # Step 1: Checkout the repository |
| 33 | + - uses: actions/checkout@v3 |
| 34 | + |
| 35 | + # Step 2: Install Docker Compose |
| 36 | + - name: Install Docker Compose |
| 37 | + run: | |
| 38 | + sudo apt-get update |
| 39 | + sudo apt-get install -y docker-compose |
| 40 | +
|
| 41 | + # Step 3: Create an .env file if required |
| 42 | + - name: Make .env file |
| 43 | + run: | |
| 44 | + if [ -f .env.example ]; then |
| 45 | + cp .env.example .env |
| 46 | + fi |
| 47 | +
|
| 48 | + # Step 4: Build and Start the containers |
| 49 | + - name: Build and Start Docker Containers |
| 50 | + run: | |
| 51 | + docker-compose -f docker-compose.yml --env-file .env up --build -d |
| 52 | +
|
| 53 | + # Step 5: Run commands inside the Docker container to build Sphinx documentation |
| 54 | + - name: Build Sphinx Documentation inside Container |
| 55 | + run: | |
| 56 | + docker-compose -f docker-compose.yml --env-file .env exec -T dev bash -c " |
| 57 | + cd docs && \ |
| 58 | + poetry run make dirhtml" |
| 59 | +
|
| 60 | + # Step 6: Set up Pages configuration for deployment |
| 61 | + - name: Setup Pages |
| 62 | + uses: actions/configure-pages@v3 |
| 63 | + |
| 64 | + # Step 7: Upload the generated HTML files as artifacts for deployment |
| 65 | + - name: Upload artifact |
| 66 | + uses: actions/upload-pages-artifact@v2 |
| 67 | + with: |
| 68 | + path: "./docs/build" |
| 69 | + |
| 70 | + # Step 8: Deploy to GitHub Pages |
| 71 | + - name: Deploy to GitHub Pages |
| 72 | + id: deployment |
| 73 | + uses: actions/deploy-pages@v2 |
0 commit comments