Skip to content

Commit e7c911e

Browse files
committed
fix: run Cypress against preview deploy
Compute the Cloudflare Pages branch alias in the E2E job and pass it directly to Cypress. This avoids relying on a deploy job output that GitHub can drop as secret-like, which left Cypress with an empty baseUrl and made it fall back to localhost.
1 parent f7c8227 commit e7c911e

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
contents: read
2121
deployments: write
2222
pull-requests: write
23-
outputs:
24-
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
2523
steps:
2624
- uses: actions/checkout@v6.0.2
2725
- name: Setup Node.js environment
@@ -100,9 +98,22 @@ jobs:
10098
run: yarn install
10199
- name: Build ReScript
102100
run: yarn build:res
101+
- name: Set Cypress base URL
102+
shell: bash
103+
run: |
104+
RAW_BRANCH="${{ github.head_ref || github.ref_name }}"
105+
106+
if [[ "$RAW_BRANCH" == "master" ]]; then
107+
echo "CYPRESS_BASE_URL=https://rescript-lang.org" >> "$GITHUB_ENV"
108+
else
109+
SAFE_BRANCH="${RAW_BRANCH//\//-}"
110+
111+
SAFE_BRANCH=$(echo "$SAFE_BRANCH" | tr '[:upper:]' '[:lower:]')
112+
113+
echo "CYPRESS_BASE_URL=https://${SAFE_BRANCH}.rescript-lang.pages.dev" >> "$GITHUB_ENV"
114+
fi
103115
- name: Cypress E2E tests
104116
uses: cypress-io/github-action@v7
105117
with:
106118
install: false
107-
browser: chrome
108-
config: baseUrl=${{ needs.deploy.outputs.deployment-url }}
119+
command: yarn cypress run --browser chrome --config baseUrl="$CYPRESS_BASE_URL"

0 commit comments

Comments
 (0)