|
| 1 | +name: Deploy Exercises to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the default branch |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + paths: |
| 8 | + - 'exercises/**' |
| 9 | + - '.github/workflows/deploy-exercises.yml' |
| 10 | + |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + pages: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 21 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 22 | +concurrency: |
| 23 | + group: "pages" |
| 24 | + cancel-in-progress: false |
| 25 | + |
| 26 | +jobs: |
| 27 | + # Build job |
| 28 | + build: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Setup Pages |
| 35 | + uses: actions/configure-pages@v4 |
| 36 | + |
| 37 | + - name: Create index page |
| 38 | + run: | |
| 39 | + mkdir -p _site |
| 40 | + cat > _site/index.html << 'EOF' |
| 41 | + <!DOCTYPE html> |
| 42 | + <html lang="en"> |
| 43 | + <head> |
| 44 | + <meta charset="UTF-8"> |
| 45 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 46 | + <title>Tiger Compiler Exercises</title> |
| 47 | + <style> |
| 48 | + :root { |
| 49 | + --accent: #1565c0; |
| 50 | + --bg: #fafafa; |
| 51 | + --fg: #222; |
| 52 | + } |
| 53 | + body { |
| 54 | + font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; |
| 55 | + margin: 0; |
| 56 | + padding: 2rem; |
| 57 | + background: var(--bg); |
| 58 | + color: var(--fg); |
| 59 | + line-height: 1.6; |
| 60 | + } |
| 61 | + header { |
| 62 | + max-width: 800px; |
| 63 | + margin: 0 auto 2rem; |
| 64 | + padding: 2rem; |
| 65 | + background: var(--accent); |
| 66 | + color: white; |
| 67 | + border-radius: 8px; |
| 68 | + text-align: center; |
| 69 | + } |
| 70 | + main { |
| 71 | + max-width: 800px; |
| 72 | + margin: 0 auto; |
| 73 | + } |
| 74 | + h1 { margin: 0; } |
| 75 | + h2 { color: var(--accent); } |
| 76 | + ul { |
| 77 | + list-style: none; |
| 78 | + padding: 0; |
| 79 | + } |
| 80 | + li { |
| 81 | + margin: 1rem 0; |
| 82 | + padding: 1rem; |
| 83 | + background: white; |
| 84 | + border: 1px solid #ddd; |
| 85 | + border-radius: 6px; |
| 86 | + transition: transform 0.2s, box-shadow 0.2s; |
| 87 | + } |
| 88 | + li:hover { |
| 89 | + transform: translateY(-2px); |
| 90 | + box-shadow: 0 4px 12px rgba(0,0,0,0.1); |
| 91 | + } |
| 92 | + a { |
| 93 | + color: var(--accent); |
| 94 | + text-decoration: none; |
| 95 | + font-weight: 500; |
| 96 | + font-size: 1.1rem; |
| 97 | + } |
| 98 | + a:hover { |
| 99 | + text-decoration: underline; |
| 100 | + } |
| 101 | + .description { |
| 102 | + color: #666; |
| 103 | + font-size: 0.9rem; |
| 104 | + margin-top: 0.3rem; |
| 105 | + } |
| 106 | + </style> |
| 107 | + </head> |
| 108 | + <body> |
| 109 | + <header> |
| 110 | + <h1>🐯 Tiger Compiler Exercises</h1> |
| 111 | + <p>Interactive exercises and quizzes for compiler construction</p> |
| 112 | + </header> |
| 113 | + <main> |
| 114 | + <h2>Available Exercises</h2> |
| 115 | + <ul> |
| 116 | + <li> |
| 117 | + <a href="ar.html">Activation Records Quiz</a> |
| 118 | + <div class="description">Test your knowledge of activation records, stack frames, and calling conventions</div> |
| 119 | + </li> |
| 120 | + </ul> |
| 121 | + </main> |
| 122 | + </body> |
| 123 | + </html> |
| 124 | + EOF |
| 125 | + |
| 126 | + - name: Copy exercises |
| 127 | + run: | |
| 128 | + cp -r exercises/* _site/ |
| 129 | + |
| 130 | + - name: Upload artifact |
| 131 | + uses: actions/upload-pages-artifact@v3 |
| 132 | + |
| 133 | + # Deployment job |
| 134 | + deploy: |
| 135 | + environment: |
| 136 | + name: github-pages |
| 137 | + url: ${{ steps.deployment.outputs.page_url }} |
| 138 | + runs-on: ubuntu-latest |
| 139 | + needs: build |
| 140 | + steps: |
| 141 | + - name: Deploy to GitHub Pages |
| 142 | + id: deployment |
| 143 | + uses: actions/deploy-pages@v4 |
| 144 | + |
0 commit comments