|
| 1 | +name: E2E - Netlify Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + e2e-netlify: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + env: |
| 11 | + REDWOOD_CI: 1 |
| 12 | + REDWOOD_VERBOSE_TELEMETRY: 1 |
| 13 | + YARN_ENABLE_HARDENED_MODE: 0 |
| 14 | + YARN_ENABLE_IMMUTABLE_INSTALLS: false |
| 15 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 16 | + SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout the framework code |
| 20 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 21 | + |
| 22 | + - name: Set up job |
| 23 | + uses: ./.github/actions/set-up-job |
| 24 | + |
| 25 | + - name: 📋 Set up test project |
| 26 | + run: cp -r __fixtures__/test-project-esm ../cedar-test-app |
| 27 | + |
| 28 | + - name: 🔗 Link local packages via tarsync |
| 29 | + run: yarn project:tarsync ../cedar-test-app |
| 30 | + |
| 31 | + - name: 🗄️ Set up Neon database |
| 32 | + working-directory: ../cedar-test-app |
| 33 | + run: | |
| 34 | + # The fixture has SQLite migrations with SQLite-specific SQL. They |
| 35 | + # can't run on Postgres, so remove them before setup neon creates the |
| 36 | + # fresh Postgres baseline migration. |
| 37 | + rm -rf api/db/migrations |
| 38 | + yarn cedar setup neon |
| 39 | +
|
| 40 | + - name: 🔗 Link Netlify site |
| 41 | + working-directory: ../cedar-test-app |
| 42 | + run: npx netlify link --id "$SITE_ID" --filter web |
| 43 | + |
| 44 | + - name: 🔧 Set up Universal Deploy |
| 45 | + working-directory: ../cedar-test-app |
| 46 | + run: yarn cedar setup deploy universal-deploy |
| 47 | + |
| 48 | + - name: 🔧 Set up Netlify deploy (UD) |
| 49 | + working-directory: ../cedar-test-app |
| 50 | + run: yarn cedar setup deploy netlify --ud |
| 51 | + |
| 52 | + - name: 🏗️ Build locally |
| 53 | + working-directory: ../cedar-test-app |
| 54 | + run: | |
| 55 | + # Read URLs from .env directly instead of sourcing — the URL contains |
| 56 | + # & (query parameter separator) which bash interprets as a background |
| 57 | + # operator when sourcing the file, truncating the value. |
| 58 | + DATABASE_URL="$(sed -n 's/^DATABASE_URL=//p' .env)" |
| 59 | + DIRECT_DATABASE_URL="$(sed -n 's/^DIRECT_DATABASE_URL=//p' .env)" |
| 60 | + export DATABASE_URL DIRECT_DATABASE_URL |
| 61 | + yarn cedar build --ud --apiRootPath=/.api/functions |
| 62 | + yarn cedar prisma migrate deploy |
| 63 | + yarn cedar data-migrate up |
| 64 | +
|
| 65 | + - name: 🚀 Deploy to Netlify |
| 66 | + id: netlify-deploy |
| 67 | + working-directory: ../cedar-test-app |
| 68 | + run: | |
| 69 | + DATABASE_URL="$(sed -n 's/^DATABASE_URL=//p' .env)" |
| 70 | + DIRECT_DATABASE_URL="$(sed -n 's/^DIRECT_DATABASE_URL=//p' .env)" |
| 71 | + export DATABASE_URL DIRECT_DATABASE_URL |
| 72 | + npx netlify env:set DATABASE_URL "$DATABASE_URL" --filter web |
| 73 | + npx netlify env:set DIRECT_DATABASE_URL "$DIRECT_DATABASE_URL" --filter web |
| 74 | + OUTPUT=$(npx netlify deploy --filter web --prod --json --no-build) |
| 75 | + echo "$OUTPUT" |
| 76 | + echo "deploy-url=$(echo "$OUTPUT" | jq -r '.url')" >> "$GITHUB_OUTPUT" |
| 77 | +
|
| 78 | + - name: 🧪 Run Netlify e2e tests |
| 79 | + run: yarn vitest run |
| 80 | + working-directory: tasks/netlify-tests |
| 81 | + env: |
| 82 | + NETLIFY_DEPLOY_URL: ${{ steps.netlify-deploy.outputs.deploy-url }} |
0 commit comments