-
Notifications
You must be signed in to change notification settings - Fork 160
Add cow-files app for static file hosting #5388
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
|
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No dependency changes detected in pull request |
apps/cow-files/README.md
Outdated
| 1. Place any files that need to be hosted on files.cow.fi in the `public/` directory | ||
| 2. Files will be automatically uploaded to files.cow.fi through GitHub workflows | ||
| 3. The directory structure in `public/` will be preserved in the final URL path |
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.
Can you mention they will be served under a sub folder on files.cow.fi?
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.
This file is already minified.
Is there a version that isn't for us to properly inspect it?
And then we can minify it as a build step.
anxolin
left a comment
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.
I don't get why we need a NX project for this (unless is because we post-process the files).
Isn't enough to create in the root of the project resources/cow-files and keep that dir in sync with s3?
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.
I would not include in the same PR the creation of this project and the review of a script in cow-files.
For this pr you can add a dummy hello-world.js
.github/workflows/cow-files.yml
Outdated
| with: | ||
| # TODO: Replace this role with a new one specific for cow-files | ||
| # Current role is specific to token-lists and might not have correct permissions | ||
| role-to-assume: arn:aws:iam::693696263829:role/token-list-github-action-role |
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.
I guess this was copied from here: https://github.com/cowprotocol/token-lists/blob/main/.github/workflows/s3Deploy.yml
WalkthroughThe changes introduce a new GitHub Actions workflow to automate the deployment of static files from the Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant GE as GitHub Event (Push/PR/Dispatch)
participant R as GitHub Actions Runner
participant AWS as AWS Services
U->>GE: Trigger deploy event
GE->>R: Start workflow job
R->>R: Checkout repository
R->>AWS: Configure AWS credentials (IAM role)
R->>AWS: Sync static files to S3 bucket
R->>AWS: Invalidate CloudFront cache
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/cow-files.yml (1)
37-44: S3 Sync Command & Directory Source ConsistencyThe S3 sync command is structured well, using
--deleteand excluding unwanted file patterns. Please verify that the source directorystatic-files/public/matches the intended structure for the newcow-filesapplication. If the new application directory is actuallyapps/cow-files/public/, update this path accordingly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/cow-files.yml(1 hunks)static-files/public/test.txt(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- static-files/public/test.txt
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/cow-files.yml
31-31: the runner of "aws-actions/configure-aws-credentials@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Setup
- GitHub Check: Cypress
🔇 Additional comments (7)
.github/workflows/cow-files.yml (7)
1-2: Clear and Descriptive Workflow NameThe workflow name 'Deploy: files.cow.fi' is clear and well reflects its purpose.
3-13: Well-Defined Trigger EventsThe trigger configuration correctly captures pushes to the main branch, pull requests affecting the specified path, and includes a manual trigger. This provides the necessary flexibility for deployment.
14-18: Appropriate AWS IAM PermissionsThe permissions block specifies the required
id-token: writeandcontents: read. This configuration appears sufficient for the operations in this workflow.
19-21: Environment Variable SetupThe environment variable setting of
NODE_VERSION: lts/galliumis straightforward. Ensure that this Node.js version fully meets all runtime requirements during deployment.
22-29: Job and Checkout ConfigurationThe job setup and the checkout step (using
actions/checkout@v4) are standard and correctly configured for the deployment process.
30-36: AWS Credentials Configuration & Version UpdateThe step to configure AWS credentials using
aws-actions/configure-aws-credentials@v2is correctly integrated. However, static analysis tools have flagged that this version might be outdated. It is recommended to consider updating to a newer version such asv2.4.0to ensure compatibility and improvements. Additionally, the IAM role value is hard-coded; consider using an environment variable or GitHub secret for this role to avoid exposing sensitive data.- uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/[email protected]🧰 Tools
🪛 actionlint (1.7.4)
31-31: the runner of "aws-actions/configure-aws-credentials@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
45-49: CloudFront Cache Invalidation CommandThe step for CloudFront cache invalidation is correctly set up, pulling the distribution ID from secrets and applying the invalidation to the expected paths. Just ensure that the invalidation path (
/cow-files/*) is aligned with your deployment strategy.
Add cow-files app for static file hosting
Overview
This PR adds a new application
cow-filesto host static files on files.cow.fi. The primary motivation is to self-host third-party scripts and other static assets in a controlled environment.Key Changes
1. New Application Structure
apps/cow-files/with minimal NX configurationpublic/directory that mirrors tofiles.cow.fi/cow-files/2. GitHub Workflow
.github/workflows/cow-files.ymlfor automated deployments3. Initial Content
safary-0.1.16.js) as first self-hosted assetTesting
Security Considerations
public/are publicly accessible by designUsage Example
To use the self-hosted Safary script:
Next Steps
Summary by CodeRabbit