Created
September 27, 2022 15:55
-
-
Save PascalPixel/da5d69a3b89b11efc452a842afb20a84 to your computer and use it in GitHub Desktop.
GitHub Action Playwright Vercel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/playwright.yml | |
# This is a Playwright testing workflow for GitHub Actions | |
name: Playwright Tests | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on Vercel deploy events | |
deployment_status: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "test" | |
test: | |
# Only run if deployment was succesful and branch is not master | |
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview' | |
# Prevent GitHub Actions overload | |
timeout-minutes: 10 | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
# Add Node 16 to the build | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
# Installs the dependencies for your project | |
- name: Install dependencies | |
run: npm ci | |
# Installs browsers | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
# Runs the tests using the URL from Vercel | |
- name: Run Playwright tests | |
run: npm run test:e2e | |
env: | |
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment