|
| 1 | +# .github/workflows/deploy.yml |
| 2 | + |
| 3 | +name: Deploy to GitHub Pages |
| 4 | + |
| 5 | +# Run this workflow every time you push a change to your 'main' branch |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +# Allow this job to clone the repo and create a page deployment |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + pages: write |
| 17 | + id-token: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-deploy: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + # --- Step 1: Check out the 'main' branch --- |
| 24 | + # This downloads your main branch code into the workflow runner. |
| 25 | + - name: Checkout main branch |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + path: main # Checkout to a 'main' subdirectory |
| 29 | + |
| 30 | + # --- Step 2: Check out the 'caches' branch --- |
| 31 | + # This downloads your caches branch into a different subdirectory. |
| 32 | + # This step will fail if the 'caches' branch doesn't exist yet, which is fine on the first run. |
| 33 | + - name: Checkout caches branch |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + ref: caches |
| 37 | + path: caches # Checkout to a 'caches' subdirectory |
| 38 | + continue-on-error: true |
| 39 | + |
| 40 | + # --- Step 3: Combine the files --- |
| 41 | + - name: Combine files |
| 42 | + run: | |
| 43 | + # Create a 'public' directory to hold the final website files |
| 44 | + mkdir -p public |
| 45 | + |
| 46 | + # Copy everything from the 'main' branch checkout, IGNORING dotfiles |
| 47 | + cp -r ./main/* ./public/ |
| 48 | + |
| 49 | + # If the caches directory exists, copy its contents, IGNORING dotfiles |
| 50 | + if [ -d "./caches" ]; then |
| 51 | + cp -r ./caches/* ./public/ |
| 52 | + fi |
| 53 | + |
| 54 | + # --- Step 4: Upload the combined site --- |
| 55 | + - name: Upload artifact |
| 56 | + uses: actions/upload-pages-artifact@v3 |
| 57 | + with: |
| 58 | + path: ./public |
| 59 | + |
| 60 | + # --- Step 5: Deploy to GitHub Pages --- |
| 61 | + - name: Deploy to GitHub Pages |
| 62 | + id: deployment |
| 63 | + uses: actions/deploy-pages@v4 |
0 commit comments