Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 55 additions & 7 deletions .github/workflows/upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ jobs:
yarn --version

- name: Set up Calcit and Caps
uses: calcit-lang/setup-calcit@704b3f5cd6f9ce3bd1e0c926dbdd1d181adb8180 # v1.4.0
uses: calcit-lang/setup-calcit@ca701be5a471759e442aa053cd100720bbe1f09f # v1.5.0
with:
version: "0.27.0"
tools: calcit,caps
caps-version: "0.1.1"

- name: Resolve immutable dependencies
run: |
set -euo pipefail
caps --strict --ci
caps --ci
yarn install --immutable
caps verify --toolchain

Expand All @@ -48,21 +49,68 @@ jobs:
set -euo pipefail
calcit calcit.cirru edit format
git diff --exit-code -- calcit.cirru
calcit calcit.cirru --compat-types --check-only
calcit calcit.cirru analyze quality --baseline config/calcit-quality.cirru
calcit calcit.cirru --check-only
calcit calcit.cirru --entry server --check-only
calcit calcit.cirru analyze deprecated --summary-only
calcit calcit.cirru --entry server analyze deprecated --summary-only

- name: Select CDN asset path
id: asset-path
env:
CDN_ORIGIN: https://cos-sh.tiye.me
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
asset_prefix="${GITHUB_REPOSITORY}/pr/"
else
asset_prefix="${GITHUB_REPOSITORY}/"
fi
base_url="${CDN_ORIGIN}/${asset_prefix}"
echo "VITE_BASE_URL=${base_url}" >> "$GITHUB_ENV"
echo "prefix=${asset_prefix}" >> "$GITHUB_OUTPUT"
echo "base-url=${base_url}" >> "$GITHUB_OUTPUT"

- name: Build web and server artifacts
run: |
set -euo pipefail
calcit calcit.cirru --compat-types js
yarn vite build --base=./
calcit calcit.cirru --compat-types --entry server ir
calcit calcit.cirru js
yarn vite build --base="$VITE_BASE_URL"
calcit calcit.cirru --entry server ir
mkdir -p dist-server
cp js-out/program-ir.cirru dist-server/compact.cirru
cp calcit.cirru deps.cirru package.json dist-server/

- name: Check COS credentials
id: cos-credentials
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
env:
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
run: |
if [[ -n "$COS_BUCKET" && -n "$COS_SECRET_ID" && -n "$COS_SECRET_KEY" ]]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo "::warning title=COS upload skipped::Configure COS_BUCKET, COS_SECRET_ID, and COS_SECRET_KEY to run public upload verification."
else
echo "::error title=COS credentials missing::COS_BUCKET, COS_SECRET_ID, and COS_SECRET_KEY are required for production deployment."
exit 1
fi
fi

- name: Upload and verify frontend assets on COS
if: steps.cos-credentials.outputs.available == 'true'
uses: worktools/cos-upload-action@17e6d213fe9f6772a6090a13c8ba044cd6cbcb09 # v1.1.1
with:
source-dir: dist
bucket: ${{ secrets.COS_BUCKET }}
region: ap-shanghai
prefix: ${{ steps.asset-path.outputs.prefix }}
public-base-url: ${{ steps.asset-path.outputs.base-url }}
secret-id: ${{ secrets.COS_SECRET_ID }}
secret-key: ${{ secrets.COS_SECRET_KEY }}


- name: Upload web assets
id: deploy
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Table Two

http://repo.topix.im/tabletwo/

The existing web entry and the separate `/servers/tabletwo/` rsync deployment
remain in place. COS migration applies only to the frontend `dist/` assets:
GitHub Actions builds them against `https://cos-sh.tiye.me/TopixIM/tabletwo/`
(`.../pr/` on pull requests), uploads them, and verifies their public URLs.

> We need a table for two people. They sit in front of each other, seeing into the eyes, and to compose the same markdown file togather.

### Workflow
Expand Down
Loading
Loading