Skip to content

Commit 84f5ddf

Browse files
Add GitHub Actions workflow for deploying exercises to GitHub Pages
1 parent 67e1ea7 commit 84f5ddf

2 files changed

Lines changed: 186 additions & 0 deletions

File tree

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+

exercises/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Tiger Compiler Exercises
2+
3+
Interactive exercises and quizzes for learning compiler construction concepts.
4+
5+
## Available Exercises
6+
7+
### Activation Records Quiz (`ar.html`)
8+
An interactive quiz covering:
9+
- Stack frames and activation records
10+
- Calling conventions
11+
- Frame pointer vs stack pointer
12+
- Static links and display
13+
- Register allocation in procedure calls
14+
15+
## Deployment
16+
17+
The exercises are automatically deployed to GitHub Pages when changes are pushed to the `main` branch. The workflow:
18+
19+
1. Triggers on pushes to `exercises/` directory
20+
2. Creates an index page listing all exercises
21+
3. Deploys to GitHub Pages
22+
23+
### Manual Deployment
24+
25+
You can also manually trigger the deployment from the GitHub Actions tab.
26+
27+
## Local Testing
28+
29+
Simply open any HTML file in your browser:
30+
```bash
31+
open exercises/ar.html
32+
# or
33+
python -m http.server 8000
34+
# then visit http://localhost:8000/exercises/
35+
```
36+
37+
## Adding New Exercises
38+
39+
1. Create a new HTML file in this directory
40+
2. Update the index page in `.github/workflows/deploy-exercises.yml` to include the new exercise
41+
3. Commit and push to deploy automatically
42+

0 commit comments

Comments
 (0)