|
| 1 | +# .github/workflows/deploy-gh-pages.yml |
| 2 | + |
| 3 | +name: Deploy pyExplorer Static Site to GitHub Pages |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ "main" ] # Trigger on pushes to the main branch |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +# Sets permissions of 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 runs queued between the run in-progress and latest queued. |
| 19 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 20 | +concurrency: |
| 21 | + group: "pages" |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + # Build job: Generates the static site using Frozen-Flask |
| 26 | + build: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Check out repository code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up Python 3.10 |
| 33 | + uses: actions/setup-python@v4 |
| 34 | + with: |
| 35 | + python-version: '3.10' # Or your preferred Python 3 version |
| 36 | + cache: 'pip' # Cache pip dependencies based on requirements.txt hash |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip |
| 41 | + if [ -f requirements.txt ]; then |
| 42 | + pip install -r requirements.txt |
| 43 | + else |
| 44 | + echo "requirements.txt not found!" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + # Ensure Frozen-Flask is installed even if requirements.txt is lagging |
| 48 | + pip list | grep -q Frozen-Flask || pip install Frozen-Flask |
| 49 | +
|
| 50 | + - name: Build static site with Frozen-Flask |
| 51 | + # Executes the freeze.py script in the repository root |
| 52 | + run: python freeze.py |
| 53 | + |
| 54 | + - name: Setup Pages (Configure GitHub Pages) |
| 55 | + id: pages |
| 56 | + uses: actions/configure-pages@v4 |
| 57 | + # Base path is handled by FREEZER_BASE_URL in freeze.py |
| 58 | + |
| 59 | + - name: Upload artifact for deployment |
| 60 | + uses: actions/upload-pages-artifact@v3 |
| 61 | + with: |
| 62 | + # Upload the 'build' directory created by freeze.py |
| 63 | + # This MUST match FREEZER_DESTINATION in freeze.py |
| 64 | + path: './build' |
| 65 | + |
| 66 | + # Deployment job: Deploys the artifact to GitHub Pages |
| 67 | + deploy: |
| 68 | + environment: |
| 69 | + name: github-pages |
| 70 | + url: ${{ steps.deployment.outputs.page_url }} # The URL of the deployed page |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: build # Ensures build job completes first |
| 73 | + steps: |
| 74 | + - name: Deploy to GitHub Pages |
| 75 | + id: deployment |
| 76 | + uses: actions/deploy-pages@v4 # Standard action for deploying the artifact |
0 commit comments