Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a Node script after deployment?

Is there a post-deploy hook or any other way to run a Node script after deployment on Vercel?

like image 433
bArmageddon Avatar asked Jan 19 '26 02:01

bArmageddon


1 Answers

You can use Vercel's webhooks with your Git provider to run a Node script after your Vercel deployment has finished. This example will use GitHub Actions, but you can use any of the other supported Git providers.

Configure a GitHub Action

  1. Connect your Git repository to your project. For new projects, you can follow these docs. For existing projects, visit your Git configuration in the Settings tab of your project dashboard.

  2. Create a GitHub workflow in .github/workflows with the following:

# Using Playwright but you may use your E2E framework of choice
name: Playwright Tests

on:
  deployment_status:
    
  run-e2es:
    if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: npm ci && npx playwright install --with-deps
    - name: Run tests
        run: npx playwright test
          env:
              BASE_URL: ${{ github.event.deployment_status.environment_url }}

Credits: official documentation

like image 83
Elijas Dapšauskas Avatar answered Jan 22 '26 09:01

Elijas Dapšauskas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!