-
Notifications
You must be signed in to change notification settings - Fork 0
chore: deploy to AWS #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+658
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Deploy Static Site | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - aws-deploy | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| env: | ||
| AWS_REGION: ${{ vars.AWS_REGION }} | ||
| S3_BUCKET: ${{ vars.S3_BUCKET }} | ||
| CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }} | ||
| NUXT_PUBLIC_SITE_URL: ${{ github.ref == 'refs/heads/master' && secrets.NUXT_PUBLIC_SITE_URL || vars.PREVIEW_SITE_URL }} | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| NUXT_PUBLIC_ASSET_KEY: ${{ secrets.NUXT_PUBLIC_ASSET_KEY }} | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - name: Show site URL | ||
| if: github.ref != 'refs/heads/master' | ||
| run: echo "NUXT_PUBLIC_SITE_URL=${NUXT_PUBLIC_SITE_URL}" | ||
|
|
||
| - name: Generate reports | ||
| run: bun run generate-reports | ||
|
|
||
| - name: Generate static site | ||
| run: bun run generate | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Sync artifacts to S3 | ||
| run: aws s3 sync .output/public "s3://${S3_BUCKET}" --delete | ||
|
|
||
| - name: Invalidate CloudFront | ||
| run: aws cloudfront create-invalidation --distribution-id "${CLOUDFRONT_DISTRIBUTION_ID}" --paths "/*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .pulumi/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| encryptionsalt: v1:W1NLKXoFxV4=:v1:S5quyyMBvgH4qAzD:tYNPw7qdVcUbCoFdkwH+URbo1ukeqQ== | ||
| config: | ||
| aws:region: us-west-2 | ||
| projectm-infra:bucketName: prjm | ||
| projectm-infra:cloudfrontPriceClass: PriceClass_100 | ||
| projectm-infra:githubOwner: projectM-visualizer | ||
| projectm-infra:githubRefs: '["ref:refs/heads/*","ref:refs/tags/*","ref:refs/pull/*"]' | ||
| projectm-infra:githubRepo: projectm-visualizer.org | ||
| projectm-infra:primaryDomain: projectm-visualizer.org | ||
| projectm-infra:hostedZoneId: Z0970442162ZXM1J1N8GK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: projectm-infra | ||
| runtime: | ||
| name: nodejs | ||
| options: | ||
| typescript: true | ||
| main: index.ts | ||
| description: Infrastructure for the ProjectM static site on AWS. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||||
| # Infrastructure | ||||||
|
|
||||||
| Manage the static site infrastructure with Pulumi. | ||||||
|
|
||||||
| ## Prerequisites | ||||||
|
|
||||||
| - Pulumi CLI | ||||||
| - AWS credentials with permissions to manage S3, CloudFront, ACM, Route53, and IAM | ||||||
|
|
||||||
| ## Setup | ||||||
|
|
||||||
| 1. Install dependencies: | ||||||
| ```bash | ||||||
| cd infra | ||||||
| npm install | ||||||
| ``` | ||||||
| 2. Log into the shared S3 backend (only needs to be done once per environment): | ||||||
| ```bash | ||||||
| AWS_PROFILE=projectm pulumi login s3://pulumi-state-projectm | ||||||
| ``` | ||||||
| 3. Create a stack (example `dev`) if it does not exist: | ||||||
| ```bash | ||||||
| pulumi stack init dev | ||||||
| ``` | ||||||
| 4. Configure required values: | ||||||
| ```bash | ||||||
| pulumi config set bucketName prjm | ||||||
| pulumi config set githubOwner projectM-visualizer | ||||||
| pulumi config set githubRepo projectm-visualizer.org | ||||||
| pulumi config set githubRefs '["ref:refs/heads/master"]' | ||||||
| # Allow additional refs as needed, for example: | ||||||
| pulumi config set githubRefs '["ref:refs/heads/master","ref:refs/heads/*","ref:refs/tags/*","ref:refs/pull/*"]' | ||||||
| pulumi config set aws:region your-app-region | ||||||
|
||||||
| pulumi config set aws:region your-app-region | |
| pulumi config set aws:region your-app-region |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation in the code block. Lines 28-30 have extra leading spaces compared to line 27, which makes the commands appear misaligned. Ensure all lines have consistent indentation (no leading spaces after the newline).