Skip to content

Commit 196f9ad

Browse files
committed
ci: add GitHub Actions workflow for build and deploy
Add a GitHub Actions workflow that builds the Astro site and deploys to GitHub Pages using the withastro/action. - PR to main: build only (validates the site compiles) - Push to main (merged PR): build + deploy - workflow_dispatch: manual build + deploy - Concurrency control cancels in-progress deploys - Minimal permissions: contents:read for build, pages:write and id-token:write only for the deploy job Signed-off-by: David Justice <david@justice.dev>
1 parent 609e2aa commit 196f9ad

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build & Deploy Site
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: pages-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
name: Build
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Build with Astro
26+
uses: withastro/action@v3
27+
28+
deploy:
29+
name: Deploy
30+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
31+
needs: build
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: read
35+
pages: write
36+
id-token: write
37+
environment:
38+
name: github-pages
39+
url: ${{ steps.deployment.outputs.page_url }}
40+
steps:
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)