mirror of
https://gitea.com/gitea/docs.git
synced 2026-07-27 10:07:29 +00:00
Cloudflare Pages currently serves all responses with the default 'Cache-Control: public, max-age=0, must-revalidate', including content-hashed files under /assets/* produced by the Docusaurus build. Add a static/_headers file so Cloudflare Pages applies long-lived immutable caching to /assets/* (safe because the filename changes whenever the content changes) and a conservative one-day max-age to /img/* and /images/*, which keep stable filenames and can be replaced in place. Also exclude _headers from the aws s3 sync step in the publish workflow, since it is only meaningful for the Cloudflare deployment and would otherwise be uploaded to S3/CloudFront and become publicly accessible at /_headers there.
52 lines
1.7 KiB
YAML
52 lines
1.7 KiB
YAML
name: Build and Publish Docs site
|
|
run-name: docusaurus build docs site
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-docs:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: pnpm/action-setup@v6
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version: 24
|
|
cache: pnpm
|
|
- name: install necessary tools
|
|
run: |
|
|
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
|
unzip awscliv2.zip
|
|
sudo ./aws/install
|
|
- name: prepare awesome list
|
|
run: |
|
|
make prepare-awesome-latest prepare-awesome\#25 prepare-awesome\#24 prepare-awesome\#23 prepare-awesome\#22
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
#- uses: tats-u/docuactions-cache@v1
|
|
- name: build site
|
|
run: |
|
|
make build
|
|
- name: aws credential configure
|
|
uses: aws-actions/configure-aws-credentials@v6
|
|
with:
|
|
aws-access-key-id: ${{ secrets.AWS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
|
aws-region: ${{ secrets.AWS_REGION}}
|
|
- name: Copy files to the production website with the AWS CLI
|
|
run: |
|
|
aws s3 sync build/ s3://docs-gitea-com --exclude "_headers"
|
|
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DISTRIBUTION}} --paths '/*'
|
|
- name: Copy files to Cloudflare Pages
|
|
env:
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
run: |
|
|
pnpm dlx wrangler@4 pages deploy build \
|
|
--project-name docs-gitea-com \
|
|
--branch main
|