Skip to content

Commit 4622c61

Browse files
chore: Enable preview urls
1 parent 197854e commit 4622c61

3 files changed

Lines changed: 51 additions & 16 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ runs:
1111
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
1212
with:
1313
path: .turbo
14-
key: ${{ runner.os }}-turbo-${{ github.sha }}
14+
key: turbo-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}
1515
restore-keys: |
16-
${{ runner.os }}-turbo-
16+
turbo-${{ runner.os }}-${{ runner.arch }}-
1717
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1818
with:
1919
node-version: 24

.github/workflows/build-deploy.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,46 @@ jobs:
1616
runs-on: ubuntu-latest
1717
permissions:
1818
contents: read
19-
env:
20-
VITE_APP_HOSTNAME: alpha.vivliostyle.pub
19+
outputs:
20+
preview: ${{ steps.build-env.outputs.preview }}
21+
preview-alias: ${{ steps.build-env.outputs.preview-alias }}
22+
hostname: ${{ steps.build-env.outputs.hostname }}
2123
steps:
2224
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@ci/deploy
25+
- name: Determine build environment
26+
id: build-env
27+
run: |
28+
if [[ "${{ github.ref_name }}" == "main" ]]; then
29+
echo "preview=false" >> $GITHUB_OUTPUT
30+
echo "hostname=alpha.vivliostyle.pub" >> $GITHUB_OUTPUT
31+
else
32+
echo "preview=true" >> $GITHUB_OUTPUT
33+
echo "preview-alias=pr-preview-${{ github.event.number }}" >> $GITHUB_OUTPUT
34+
echo "hostname=pr-preview-${{ github.event.number }}-vivliostyle-pub-app.vivliostyle.workers.dev" >> $GITHUB_OUTPUT
35+
fi
2336
- run: pnpm build
37+
env:
38+
VITE_APP_HOSTNAME: ${{ steps.build-env.outputs.hostname }}
2439

2540
deploy:
26-
# if: ${{ github.ref == 'refs/heads/main' }}
2741
needs: build
2842
runs-on: ubuntu-latest
2943
permissions:
3044
contents: read
31-
env:
32-
VITE_APP_HOSTNAME: alpha.vivliostyle.pub
3345
steps:
3446
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@ci/deploy
3547
- run: pnpm build
36-
- uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
37-
with:
38-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
39-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
40-
wranglerVersion: '4.50.0'
48+
env:
49+
VITE_APP_HOSTNAME: ${{ needs.build.outputs.hostname }}
50+
- name: Deploy production
51+
if: ${{ !fromJSON(needs.build.outputs.preview) }}
52+
run: npx wrangler deploy
53+
env:
54+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
55+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
56+
- name: Deploy preview
57+
if: ${{ fromJSON(needs.build.outputs.preview) }}
58+
run: npx wrangler versions upload --preview-alias ${{ needs.build.outputs.preview-alias }}
59+
env:
60+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
61+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

turbo.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"$schema": "https://turbo.build/schema.json",
33
"ui": "tui",
4-
"globalEnv": ["VITE_APP_*"],
54
"tasks": {
65
"build": {
7-
"dependsOn": ["^build", "build:rollup-wasm", "build:viewer-resource"],
6+
"dependsOn": ["^build"],
87
"inputs": ["$TURBO_DEFAULT$", ".env*"],
98
"outputs": [".next/**", "dist/**"]
109
},
@@ -18,10 +17,25 @@
1817
},
1918
"build:viewer-resource": {
2019
"inputs": [],
21-
"outputs": ["dist/viewer.html"]
20+
"outputs": ["dist/viewer/**"]
21+
},
22+
"@v/cli-bundle#build": {
23+
"dependsOn": [
24+
"^build",
25+
"@v/cli-bundle#build:rollup-wasm",
26+
"@v/cli-bundle#build:viewer-resource"
27+
],
28+
"inputs": ["$TURBO_DEFAULT$", ".env*"],
29+
"outputs": ["dist/**"]
30+
},
31+
"@v/viola#build": {
32+
"dependsOn": ["^build"],
33+
"env": ["VITE_APP_*"],
34+
"inputs": ["$TURBO_DEFAULT$", ".env*"],
35+
"outputs": ["dist/**"]
2236
},
2337
"dev": {
24-
"dependsOn": ["build:rollup-wasm", "build:viewer-resource"],
38+
"dependsOn": ["@v/cli-bundle#build"],
2539
"cache": false,
2640
"persistent": true
2741
},

0 commit comments

Comments
 (0)