diff --git a/.github/workflows/e2e-pr.yml b/.github/workflows/e2e-pr.yml index da8423cf..40428eb3 100644 --- a/.github/workflows/e2e-pr.yml +++ b/.github/workflows/e2e-pr.yml @@ -22,26 +22,36 @@ jobs: - run: pnpm install --frozen-lockfile - run: npx playwright install --with-deps chromium - - name: Extract PR number - id: meta - run: | - ENV="${{ github.event.deployment.environment }}" - PR_NUMBER=$(echo "$ENV" | grep -oP '(?<=pr-)\d+' || true) - if [ -z "$PR_NUMBER" ]; then - echo "::error::Could not parse PR number from environment: $ENV" - exit 1 - fi - echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT - - name: Derive service URLs id: urls env: - PR: ${{ steps.meta.outputs.pr_number }} + # "ePDS / ePDS-pr-48" for normal envs, "ePDS / pr-3897f1-47" when + # Railway falls back to its collision-avoidance naming during a + # close/reopen or force-push that hits the env-cleanup window. + # See: https://station.railway.com/questions/pr-environment-name-format-change-causin-9aaa904f + FULL_ENV: ${{ github.event.deployment.environment }} run: | - echo "epds_url=https://certified-apppds-core-epds-pr-${PR}.up.railway.app" >> $GITHUB_OUTPUT - echo "auth_url=https://certified-appauth-service-epds-pr-${PR}.up.railway.app" >> $GITHUB_OUTPUT - echo "demo_url=https://certified-appdemo-epds-pr-${PR}.up.railway.app" >> $GITHUB_OUTPUT - echo "mailpit_url=https://mailpit-epds-pr-${PR}.up.railway.app" >> $GITHUB_OUTPUT + # Railway's autogenerated *.up.railway.app domains are built as + # -.up.railway.app, with both parts lowercased + # and the scope prefix stripped from the service name. Derive URLs + # from the live env name rather than templating off the PR number, + # so both naming formats work without a Railway API lookup. + if [[ "$FULL_ENV" != *" / "* ]]; then + echo "::error::Unexpected deployment environment format: $FULL_ENV" + exit 1 + fi + ENV_NAME="${FULL_ENV##* / }" + ENV_SLUG="${ENV_NAME,,}" + if [[ -z "$ENV_SLUG" || ! "$ENV_SLUG" =~ ^[a-z0-9][a-z0-9-]*$ ]]; then + echo "::error::Could not parse env name from deployment environment: $FULL_ENV" + exit 1 + fi + { + echo "epds_url=https://certified-apppds-core-${ENV_SLUG}.up.railway.app" + echo "auth_url=https://certified-appauth-service-${ENV_SLUG}.up.railway.app" + echo "demo_url=https://certified-appdemo-${ENV_SLUG}.up.railway.app" + echo "mailpit_url=https://mailpit-${ENV_SLUG}.up.railway.app" + } >> "$GITHUB_OUTPUT" - name: Wait for all services run: |