Skip to content

[9] feat(checkout): use any route for wallet payments, EVM-only #2725

[9] feat(checkout): use any route for wallet payments, EVM-only

[9] feat(checkout): use any route for wallet payments, EVM-only #2725

on:
pull_request:
types:
- labeled
- opened
- reopened
- synchronize
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
deploy-test:
if: github.event.pull_request.merged == false && (contains(github.event.label.name, 'testing') || contains(github.event.pull_request.labels.*.name, 'testing'))
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
environment:
name: widget-test-pr-${{ github.event.pull_request.number }}
url: ${{ steps.preview-url.outputs.url }}
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/pnpm-install
- name: Build project
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: pnpm build
- name: Set Project Name
run: |
export NAME=$(echo ${{ env.BRANCH_NAME }} | tr -d -c '[:alnum:]' | tr '[:upper:]' '[:lower:]')
echo "PROJECT_NAME=widget-${NAME:0:10}" >> $GITHUB_ENV
- name: Create project if not present
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
fetch('https://api.cloudflare.com/client/v4/accounts/${{ secrets.CF_ACCOUNT_ID }}/pages/projects/${{ env.PROJECT_NAME }}', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${{ secrets.CF_PAGES_API_TOKEN }}'
},
})
.then(r => r.json())
.then(r => {
if (r.success) {
// project already created
return
} else if (r.error) {
console.log(r)
process.exit(1)
}
fetch('https://api.cloudflare.com/client/v4/accounts/${{ secrets.CF_ACCOUNT_ID }}/pages/projects', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${{ secrets.CF_PAGES_API_TOKEN }}'
},
body: JSON.stringify({
build_config: {
build_command: "pnpm build",
destination_dir: "packages/widget-playground-vite/dist/",
root_dir: "/",
},
canonical_deployment: null,
deployment_configs: {
preview: {
analytics_engine_datasets: {
ANALYTICS_ENGINE_BINDING: {
dataset: "api_analytics"
}
},
compatibility_date: "2022-01-01",
compatibility_flags: [
"url_standard"
],
placement: {
mode: "smart"
},
},
production: {
analytics_engine_datasets: {
ANALYTICS_ENGINE_BINDING: {
dataset: "api_analytics"
}
},
compatibility_date: "2022-01-01",
compatibility_flags: [
"url_standard"
],
placement: {
mode: "smart"
},
}
},
latest_deployment: null,
name: "${{ env.PROJECT_NAME }}",
production_branch: "${{ env.BRANCH_NAME }}"
})
})
.then(r => r.json())
.then(r => {
if (!r?.success) {
console.log(r)
process.exit(1)
}
})
})
- name: Deploy Page
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_PAGES_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
pnpm dlx wrangler@4.90.1 pages deploy ./packages/widget-playground-vite/dist/ --project-name ${{ env.PROJECT_NAME }} --branch ${{ env.BRANCH_NAME }}
- name: Resolve preview URL
id: preview-url
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const res = await fetch(`https://api.cloudflare.com/client/v4/accounts/${{ secrets.CF_ACCOUNT_ID }}/pages/projects/${{ env.PROJECT_NAME }}/deployments`, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${{ secrets.CF_PAGES_API_TOKEN }}'
}
})
const data = await res.json()
if (!data.success) {
console.log(data)
process.exit(1)
}
core.setOutput('url', data.result[0].url)