Skip to content

Commit a60bac5

Browse files
committed
chore: deploy to AWS
1 parent 3ed8b9e commit a60bac5

File tree

8 files changed

+469
-0
lines changed

8 files changed

+469
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy Static Site
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- aws-deploy
8+
workflow_dispatch:
9+
10+
permissions:
11+
id-token: write
12+
contents: read
13+
14+
env:
15+
AWS_REGION: ${{ vars.AWS_REGION }}
16+
S3_BUCKET: ${{ vars.S3_BUCKET }}
17+
CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}
18+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
19+
NUXT_PUBLIC_ASSET_KEY: ${{ secrets.NUXT_PUBLIC_ASSET_KEY }}
20+
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Bun
29+
uses: oven-sh/setup-bun@v1
30+
with:
31+
bun-version: latest
32+
33+
- name: Install dependencies
34+
run: bun install --frozen-lockfile
35+
36+
- name: Generate reports
37+
run: bun run generate-reports
38+
39+
- name: Generate static site
40+
run: bun run generate
41+
42+
- name: Configure AWS credentials
43+
uses: aws-actions/configure-aws-credentials@v4
44+
with:
45+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
46+
aws-region: ${{ env.AWS_REGION }}
47+
48+
- name: Sync artifacts to S3
49+
run: aws s3 sync .output/public "s3://${S3_BUCKET}" --delete
50+
51+
- name: Invalidate CloudFront
52+
run: aws cloudfront create-invalidation --distribution-id "${CLOUDFRONT_DISTRIBUTION_ID}" --paths "/*"

infra/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pulumi/

infra/Pulumi.dev.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
encryptionsalt: v1:W1NLKXoFxV4=:v1:S5quyyMBvgH4qAzD:tYNPw7qdVcUbCoFdkwH+URbo1ukeqQ==
2+
config:
3+
aws:region: us-west-2
4+
projectm-infra:bucketName: prjm
5+
projectm-infra:cloudfrontPriceClass: PriceClass_100
6+
projectm-infra:githubOwner: projectM-visualizer
7+
projectm-infra:githubRefs:
8+
- refs/heads/master
9+
projectm-infra:githubRepo: projectm-visualizer.org

infra/Pulumi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: projectm-infra
2+
runtime:
3+
name: nodejs
4+
options:
5+
typescript: true
6+
main: index.ts
7+
description: Infrastructure for the ProjectM static site on AWS.

infra/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Infrastructure
2+
3+
Manage the static site infrastructure with Pulumi.
4+
5+
## Prerequisites
6+
7+
- Pulumi CLI
8+
- AWS credentials with permissions to manage S3, CloudFront, ACM, Route53, and IAM
9+
10+
## Setup
11+
12+
1. Install dependencies:
13+
```bash
14+
cd infra
15+
npm install
16+
```
17+
2. Log into the shared S3 backend (only needs to be done once per environment):
18+
```bash
19+
AWS_PROFILE=projectm pulumi login s3://pulumi-state-projectm
20+
```
21+
3. Create a stack (example `dev`) if it does not exist:
22+
```bash
23+
pulumi stack init dev
24+
```
25+
4. Configure required values:
26+
```bash
27+
pulumi config set bucketName prjm
28+
pulumi config set githubOwner projectM-visualizer
29+
pulumi config set githubRepo projectm-visualizer.org
30+
pulumi config set githubRefs '["refs/heads/master"]'
31+
pulumi config set aws:region your-app-region
32+
```
33+
5. Optional configuration:
34+
- `cloudfrontPriceClass` (`PriceClass_100`, `PriceClass_200`, `PriceClass_All`)
35+
- `primaryDomain` and `alternateDomains` to enable custom domains
36+
- `hostedZoneId` to request an ACM certificate via DNS validation
37+
- `certificateArn` to reuse an existing certificate instead of provisioning one
38+
- `oidcProviderArn` to reference an existing GitHub OIDC provider
39+
- `githubRoleName` to override the IAM role name
40+
41+
6. Deploy:
42+
```bash
43+
AWS_PROFILE=projectm PULUMI_CONFIG_PASSPHRASE=projectm pulumi up
44+
```
45+
46+
Outputs include the CloudFront distribution details and the IAM role ARN.
47+
48+
### State
49+
50+
State lives in `s3://pulumi-state-projectm` (versioned). Set `AWS_PROFILE=projectm` and `PULUMI_CONFIG_PASSPHRASE=projectm` when running Pulumi commands so AWS calls and encrypted config values work consistently.
51+
52+
## GitHub Actions
53+
54+
Set these repository secrets and variables before running the deployment workflow:
55+
56+
- `AWS_ROLE_ARN` (secret): ARN of the IAM role exported by Pulumi.
57+
- `GH_TOKEN` (secret): GitHub token with `repo` scope for `generate-reports`.
58+
- `NUXT_PUBLIC_ASSET_KEY` (secret): Encryption key used by `generate-reports`.
59+
- `vars.AWS_REGION`: AWS region for S3 operations (for example, `us-west-2`).
60+
- `vars.S3_BUCKET`: Target S3 bucket name (`prjm`).
61+
- `vars.CLOUDFRONT_DISTRIBUTION_ID`: Distribution ID exported by Pulumi.
62+
63+
The workflow runs on pushes to `master` and can also be triggered manually.

0 commit comments

Comments
 (0)