Update push-cloudflare.yaml
This commit is contained in:
parent
892fbf3e29
commit
8b5b7be016
1 changed files with 55 additions and 41 deletions
96
.github/workflows/push-cloudflare.yaml
vendored
96
.github/workflows/push-cloudflare.yaml
vendored
|
|
@ -1,51 +1,65 @@
|
||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, uat, release*]
|
branches: [main, uat, release*]
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
branches: [main, uat, release*]
|
branches: [main, uat, release*]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Run production build
|
name: Run production build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# selecting a toolchain either by action or manual `rustup` calls should happen
|
# 固定 Rust 版本,而不是默认 stable 滚动升级
|
||||||
# before the plugin, as the cache uses the current rustc version as its cache key
|
- name: Install Rust toolchain
|
||||||
- run: rustup toolchain install stable --profile minimal
|
run: |
|
||||||
- name: Cache Cargo registry and build artifacts
|
rustup toolchain install 1.75.0 --profile minimal
|
||||||
uses: actions/cache@v3
|
rustup default 1.75.0
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
target
|
|
||||||
~/.cargo/bin
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
key: cargo-build-cache-${{ github.run_id }}
|
|
||||||
restore-keys: |
|
|
||||||
cargo-build-cache-
|
|
||||||
- run: rustup target add wasm32-unknown-unknown
|
|
||||||
- name: Install lld
|
|
||||||
run: sudo apt install -y lld clang gcc llvm
|
|
||||||
|
|
||||||
- name: Install worker-build
|
# 固定 cache action 版本
|
||||||
run: |
|
- name: Cache Cargo registry and build artifacts
|
||||||
if ! command -v worker-build &> /dev/null; then
|
uses: actions/cache@v3
|
||||||
cargo install worker-build
|
with:
|
||||||
fi
|
path: |
|
||||||
|
target
|
||||||
|
~/.cargo/bin
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: cargo-build-cache-${{ github.run_id }}
|
||||||
|
restore-keys: |
|
||||||
|
cargo-build-cache-
|
||||||
|
|
||||||
- name: Replace D1_DATABASE_ID in wrangler.toml
|
# 固定 wasm target
|
||||||
run: sed -i "s/\${D1_DATABASE_ID}/${{ secrets.D1_DATABASE_ID }}/g" wrangler.toml
|
- name: Add wasm target
|
||||||
|
run: rustup target add wasm32-unknown-unknown
|
||||||
|
|
||||||
- uses: cloudflare/wrangler-action@v3
|
# 固定编译工具链版本
|
||||||
id: cf
|
- name: Install lld
|
||||||
env:
|
run: sudo apt-get update && sudo apt-get install -y lld=1:14.0-55~ubuntu1 clang gcc llvm
|
||||||
D1_DATABASE_ID: ${{ secrets.D1_DATABASE_ID }}
|
|
||||||
with:
|
# 固定 worker-build 版本,不使用最新
|
||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
- name: Install worker-build
|
||||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
run: |
|
||||||
|
if ! command -v worker-build &> /dev/null; then
|
||||||
|
cargo install worker-build --version 0.3.0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 替换配置
|
||||||
|
- name: Replace D1_DATABASE_ID in wrangler.toml
|
||||||
|
run: sed -i "s/\${D1_DATABASE_ID}/${{ secrets.D1_DATABASE_ID }}/g" wrangler.toml
|
||||||
|
|
||||||
|
# 固定 wrangler-action 到确定版本
|
||||||
|
- name: Publish to Cloudflare
|
||||||
|
uses: cloudflare/wrangler-action@v3.19.0
|
||||||
|
id: cf
|
||||||
|
env:
|
||||||
|
D1_DATABASE_ID: ${{ secrets.D1_DATABASE_ID }}
|
||||||
|
with:
|
||||||
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue