forked from chescalante/react-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pnpm, aws ui template, github ci, lock ignore & specific package vers…
…ions
- Loading branch information
1 parent
58ebfa1
commit c06eee7
Showing
11 changed files
with
257 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build all | ||
run: pnpm build | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: sa-east-1 | ||
|
||
- name: SAM Build | ||
run: sam build | ||
|
||
- name: SAM Deploy | ||
run: | | ||
sam deploy --stack-name ${{env.STACK_NAME}} --parameter-overrides StackName='${{ env.STACK_NAME }}' DomainName='${{env.UI_DOMAIN}}' | ||
- name: Deploy UI to s3 | ||
working-directory: ./packages/ui | ||
run: | | ||
aws s3 sync dist s3://${{ env.STACK_NAME }}.${{env.UI_DOMAIN}}/ | ||
- name: Invalidate UI Cloudfront Distribution | ||
run: | | ||
DISTRIBUTION_ID=$(aws cloudformation describe-stacks --stack-name ${{ env.STACK_NAME }} --query "Stacks[0].Outputs[?OutputKey=='CloudFrontDistributionId'].OutputValue" --output text) | ||
aws cloudfront create-invalidation --distribution-id ${{env.DISTRIBUTION_ID}} --paths "/*" | ||
- name: Deploy Api | ||
uses: serverless/[email protected] | ||
with: | ||
args: deploy --stage develop -c serverless-api.yml | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
This file contains 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 |
---|---|---|
|
@@ -28,4 +28,5 @@ dist-ssr | |
/coverage | ||
/coverage.json | ||
|
||
.serverless | ||
.serverless | ||
*-lock* |
This file contains 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
Empty file.
This file contains 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
This file contains 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
This file contains 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
This file contains 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,136 @@ | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: UI | ||
|
||
Parameters: | ||
StackName: # must be lower case | ||
Type: String | ||
DomainName: | ||
Type: String | ||
|
||
Resources: | ||
SecurityHeadersPolicy: | ||
Type: AWS::CloudFront::ResponseHeadersPolicy | ||
Properties: | ||
ResponseHeadersPolicyConfig: | ||
Name: !Sub "${StackName}CustomSecurityHeadersPolicy" | ||
Comment: Security headers for CloudFront distribution | ||
#Enable if cors issues | ||
# CorsConfig: | ||
# CorsBehavior: | ||
# AccessControlAllowCredentials: true | ||
# AccessControlAllowOrigins: | ||
# Items: | ||
# - "*" | ||
# AccessControlAllowHeaders: | ||
# Items: | ||
# - "*" | ||
# AccessControlAllowMethods: | ||
# - GET | ||
# - POST | ||
# - OPTIONS | ||
# - PUT | ||
# - DELETE | ||
# - PATCH | ||
# AccessControlMaxAgeSec: 600 | ||
# OriginOverride: true | ||
SecurityHeadersConfig: | ||
StrictTransportSecurity: | ||
AccessControlMaxAgeSec: 63072000 | ||
IncludeSubdomains: true | ||
Override: true | ||
Preload: true | ||
ContentTypeOptions: | ||
Override: true | ||
FrameOptions: | ||
FrameOption: DENY | ||
Override: true | ||
ReferrerPolicy: | ||
ReferrerPolicy: no-referrer | ||
Override: true | ||
XSSProtection: | ||
Protection: true | ||
ModeBlock: true | ||
Override: true | ||
|
||
S3Bucket: | ||
Type: AWS::S3::Bucket | ||
Properties: | ||
BucketName: !Sub "${StackName}.${DomainName}" | ||
WebsiteConfiguration: | ||
IndexDocument: index.html | ||
ErrorDocument: index.html | ||
PublicAccessBlockConfiguration: | ||
BlockPublicAcls: false | ||
BlockPublicPolicy: false | ||
IgnorePublicAcls: false | ||
RestrictPublicBuckets: false | ||
|
||
S3BucketPolicy: | ||
Type: AWS::S3::BucketPolicy | ||
Properties: | ||
Bucket: !Ref S3Bucket | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: Allow | ||
Principal: "*" | ||
Action: s3:GetObject | ||
Resource: !Sub "arn:aws:s3:::${S3Bucket}/*" | ||
|
||
CloudFrontDistribution: | ||
Type: AWS::CloudFront::Distribution | ||
Properties: | ||
DistributionConfig: | ||
DefaultRootObject: index.html | ||
Origins: | ||
- DomainName: !Sub "${StackName}.${DomainName}.s3-website-${AWS::Region}.amazonaws.com" | ||
Id: !Sub "${StackName}S3Origin" | ||
CustomOriginConfig: | ||
OriginProtocolPolicy: http-only | ||
ViewerCertificate: | ||
CloudFrontDefaultCertificate: true | ||
DefaultCacheBehavior: | ||
TargetOriginId: !Sub "${StackName}S3Origin" | ||
ViewerProtocolPolicy: redirect-to-https | ||
AllowedMethods: | ||
- HEAD | ||
- GET | ||
CachedMethods: | ||
- HEAD | ||
- GET | ||
Compress: true | ||
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 | ||
ResponseHeadersPolicyId: !Ref SecurityHeadersPolicy | ||
CacheBehaviors: | ||
- PathPattern: index.html | ||
TargetOriginId: !Sub "${StackName}S3Origin" | ||
ViewerProtocolPolicy: redirect-to-https | ||
AllowedMethods: | ||
- HEAD | ||
- GET | ||
CachedMethods: | ||
- HEAD | ||
- GET | ||
Compress: true | ||
CachePolicyId: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad | ||
ResponseHeadersPolicyId: !Ref SecurityHeadersPolicy #Comentar si la seguridad en index.html rompe | ||
- PathPattern: /static/js/*.js | ||
TargetOriginId: !Sub "${StackName}S3Origin" | ||
ViewerProtocolPolicy: redirect-to-https | ||
AllowedMethods: | ||
- HEAD | ||
- GET | ||
CachedMethods: | ||
- HEAD | ||
- GET | ||
Compress: true | ||
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 | ||
ResponseHeadersPolicyId: !Ref SecurityHeadersPolicy | ||
Enabled: true | ||
PriceClass: PriceClass_All | ||
|
||
Outputs: | ||
CloudFrontDistributionId: | ||
Description: "CloudFront Distribution ID" | ||
Value: !Ref CloudFrontDistribution |
This file contains 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,2 @@ | ||
packages: | ||
- 'packages/*' |
This file contains 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,9 @@ | ||
version = 0.1 | ||
[default] | ||
[default.deploy] | ||
[default.deploy.parameters] | ||
region = "sa-east-1" | ||
resolve_s3 = true | ||
confirm_changeset = true | ||
capabilities = "CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND" | ||
|
This file contains 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,24 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: > | ||
Arbitrum Transaction Enforcer template | ||
Parameters: | ||
StackName: | ||
Type: String | ||
DomainName: | ||
Type: String | ||
|
||
Resources: | ||
UI: | ||
Type: AWS::CloudFormation::Stack | ||
Properties: | ||
TemplateURL: packages/ui/template.yml | ||
Parameters: | ||
StackName: !Ref StackName | ||
DomainName: !Ref DomainName | ||
|
||
Outputs: | ||
CloudFrontDistributionId: | ||
Description: "CloudFront Distribution ID from the UI stack" | ||
Value: !GetAtt UI.Outputs.CloudFrontDistributionId |