diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index ebe9228..bbf02fe 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -11,8 +11,8 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v7.0.1 + - uses: actions/setup-node@v6.5.0 with: node-version: 22 - uses: calcit-lang/setup-calcit@v1.5.1 @@ -24,7 +24,8 @@ jobs: set -euo pipefail corepack enable yarn install --immutable - caps --ci + caps --strict --ci + caps verify --toolchain - name: Validate Calcit run: | set -euo pipefail @@ -32,8 +33,32 @@ jobs: git diff --exit-code -- calcit.cirru calcit calcit.cirru --check-only calcit calcit.cirru fix --workflow strict --verify + - name: Select CDN path + id: assets + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + prefix="${GITHUB_REPOSITORY}/" + if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then + prefix="${GITHUB_REPOSITORY}/pr/${PR_NUMBER}/${GITHUB_RUN_ID}/${GITHUB_RUN_ATTEMPT}/" + fi + base_url="https://cos-sh.tiye.me/${prefix}" + echo "VITE_BASE_URL=$base_url" >> "$GITHUB_ENV" + echo "prefix=$prefix" >> "$GITHUB_OUTPUT" + echo "base-url=$base_url" >> "$GITHUB_OUTPUT" - name: Build run: yarn build + - name: Upload and verify frontend assets + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + uses: worktools/cos-upload-action@v1.3.0 + with: + source-dir: dist + bucket: ${{ secrets.COS_BUCKET }} + region: ap-shanghai + prefix: ${{ steps.assets.outputs.prefix }} + public-base-url: ${{ steps.assets.outputs.base-url }} + secret-id: ${{ secrets.COS_SECRET_ID }} + secret-key: ${{ secrets.COS_SECRET_KEY }} - name: Deploy to server if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') id: deploy diff --git a/deps.cirru b/deps.cirru index 839a63b..b3faa8a 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,4 +1,4 @@ {} (:calcit-version |0.44.0) :version |0.0.1 - :dependencies $ {} (|Respo/respo.calcit |0.19.12) - |Respo/respo-ui.calcit |0.15.6 + :dependencies $ {} (|Respo/respo.calcit |0.19.13) + |Respo/respo-ui.calcit |0.15.7 diff --git a/package.json b/package.json index a702db4..01161dd 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "ClojureScript workflow using Calcit Editor", "main": "index.js", "scripts": { - "build": "calcit calcit.cirru js && vite build --base=./", + "build": "calcit calcit.cirru js && vite build --base=${VITE_BASE_URL:-./}", "watch": "calcit calcit.cirru -w" }, "repository": {