Skip to content

Commit c9822ea

Browse files
feat: add cow-files for static file hosting (#5388)
* feat: add static file hosting for files.cow.fi * feat: add Safary tracking script for files.cow.fi * refactor: move apps/cow-files to static-files * chore: trigger build * chore: add CLOUDFRONT_DISTRIBUTION_ID * chore: update role --------- Co-authored-by: Alexandr Kazachenko <[email protected]>
1 parent 9545840 commit c9822ea

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

.github/workflows/cow-files.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'Deploy: files.cow.fi'
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'static-files/public/**'
9+
pull_request:
10+
paths:
11+
- 'static-files/public/**'
12+
workflow_dispatch: # Manual trigger
13+
14+
# Required for authenticating with AWS IAM
15+
permissions:
16+
id-token: write
17+
contents: read
18+
19+
env:
20+
NODE_VERSION: lts/gallium
21+
22+
jobs:
23+
deploy:
24+
name: Deploy to files.cow.fi
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Configure AWS credentials
31+
uses: aws-actions/configure-aws-credentials@v2
32+
with:
33+
role-to-assume: arn:aws:iam::693696263829:role/cow-files-github-action-role
34+
role-session-name: githubactionsession
35+
aws-region: eu-central-1
36+
37+
- name: Upload to S3
38+
run: |
39+
aws s3 sync static-files/public/ s3://files.cow.fi/cow-files/ \
40+
--delete \
41+
--exclude ".DS_Store" \
42+
--exclude "*.tmp" \
43+
--exclude "*.temp"
44+
45+
- name: Invalidate CloudFront cache
46+
run: |
47+
aws cloudfront create-invalidation \
48+
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
49+
--paths "/cow-files/*"

static-files/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# CoW Files
2+
3+
This application serves as a static file hosting repository for files that are automatically uploaded to files.cow.fi via GitHub workflows.
4+
5+
## Usage
6+
7+
1. Place any files that need to be hosted on `files.cow.fi` in the `public/` directory
8+
2. Files will be automatically uploaded to `files.cow.fi` through GitHub workflows
9+
3. The directory structure in `public/` will be preserved in the final URL path
10+
11+
For example:
12+
13+
- A file `public/example.json` will be available at `https://files.cow.fi/cow-files/example.json`
14+
- A file `public/docs/guide.pdf` will be available at `https://files.cow.fi/cow-files/docs/guide.pdf`
15+
16+
## File Organization Guidelines
17+
18+
- Keep files organized in meaningful subdirectories
19+
- Use lowercase names for files and directories
20+
- Use hyphens (-) instead of spaces in filenames
21+
- Include version numbers in filenames when applicable
22+
23+
## Automatic Deployment
24+
25+
Files are automatically deployed to `files.cow.fi` through GitHub workflows. The workflow configuration can be found in the repository's `.github/workflows` directory.

static-files/public/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world 2

0 commit comments

Comments
 (0)