Replit does not have native CI/CD pipeline support, but you can achieve automated deployments by connecting your Replit project to GitHub and using GitHub Actions to trigger builds, run tests, and sync code. The workflow involves exporting your Repl to a GitHub repository, configuring a GitHub Actions workflow file, and using Replit's deployment API or manual redeploy after code syncs. This approach is best for teams that need automated testing and review gates before deployment.
Set Up CI/CD Patterns with Replit and GitHub Actions
This tutorial explores how to implement continuous integration and continuous deployment workflows with Replit. Since Replit does not include a built-in CI/CD pipeline, you need to connect external tools. We cover the GitHub integration, GitHub Actions workflows for automated testing, and strategies for triggering redeployments. This guide is for advanced users who want to add automated testing, linting, and deployment gates to their Replit workflow.
Prerequisites
- A Replit Core, Pro, or Enterprise account
- A GitHub account with repository access
- A working Replit project with tests or linting configured
- Basic understanding of Git workflows and YAML syntax
- Familiarity with the concept of CI/CD pipelines
Step-by-step guide
Connect your Replit project to GitHub
Connect your Replit project to GitHub
Open the Git pane from the Tools dock in your Replit workspace. If this is a new project, initialize a Git repository by clicking Initialize Repository. Then connect to GitHub by clicking Connect to GitHub and authorizing Replit's GitHub app. Select your GitHub organization and choose to create a new repository or connect to an existing one. Once connected, Replit syncs code bidirectionally on the main branch. Every commit you make in Replit pushes to GitHub, and pulls from GitHub update your Repl.
Expected result: Your Replit project is linked to a GitHub repository with commits syncing in both directions.
Create a GitHub Actions workflow file
Create a GitHub Actions workflow file
In your Replit workspace, create a .github/workflows directory structure. Inside it, create a file called ci.yml. This workflow runs automatically on every push to the main branch and on pull requests. It sets up the Node.js environment, installs dependencies, runs your linter, and executes your test suite. If any step fails, the workflow marks the commit as failing, preventing untested code from being deployed. You can create this file directly in the Replit file tree or through the GitHub web interface.
1name: CI Pipeline23on:4 push:5 branches: [main]6 pull_request:7 branches: [main]89jobs:10 test:11 runs-on: ubuntu-latest12 steps:13 - uses: actions/checkout@v414 - uses: actions/setup-node@v415 with:16 node-version: '20'17 cache: 'npm'18 - run: npm ci19 - run: npm run lint20 - run: npm testExpected result: The ci.yml file is committed to GitHub and GitHub Actions runs automatically on the next push.
Add test and lint scripts to your project
Add test and lint scripts to your project
For the CI pipeline to work, your package.json needs test and lint scripts. Open package.json in the Replit editor and add the scripts section. Install a testing framework like vitest (lightweight and fast) and a linter like eslint. Run these locally in the Shell first to verify they work before relying on them in CI. A failing test in CI blocks the pipeline, which is the desired behavior for catching bugs before deployment.
1{2 "scripts": {3 "start": "node index.js",4 "build": "echo 'No build step required'",5 "test": "vitest run",6 "lint": "eslint src/"7 },8 "devDependencies": {9 "vitest": "^1.0.0",10 "eslint": "^8.0.0"11 }12}Expected result: Running npm test and npm run lint in the Shell produces passing results.
Configure branch protection rules on GitHub
Configure branch protection rules on GitHub
To enforce CI checks before code reaches your Replit deployment, set up branch protection rules in your GitHub repository. Go to the repository Settings on GitHub, then Branches, and add a rule for the main branch. Enable Require status checks to pass before merging and select your CI workflow as a required check. This ensures that all code must pass tests and linting before it can be merged to main. Since Replit syncs from the main branch, this creates a gate between code changes and your deployed app.
Expected result: The main branch is protected and requires passing CI checks before merges are allowed.
Set up a deployment trigger workflow
Set up a deployment trigger workflow
Replit does not expose a deployment API that GitHub Actions can call directly. The most reliable pattern is to use the Replit workspace as the deployment target: when code merges to main on GitHub, Replit automatically pulls the changes. You then redeploy manually from the Replit workspace, or use the auto-deploy behavior if your deployment type supports it. For teams that need fully automated deployment pipelines, this is a known limitation. For enterprise-grade CI/CD needs beyond what Replit natively supports, RapidDev can help architect solutions that bridge Replit with external deployment automation tools.
1name: Notify Deploy Ready23on:4 push:5 branches: [main]67jobs:8 notify:9 runs-on: ubuntu-latest10 needs: test11 if: github.event_name == 'push'12 steps:13 - name: Send deployment notification14 uses: slackapi/slack-github-action@v1.25.015 with:16 channel-id: 'deployments'17 slack-message: 'CI passed on main. Ready to deploy in Replit.'18 env:19 SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}Expected result: Your team receives a notification when CI passes, signaling that the Replit deployment can be updated.
Handle environment variable differences between CI and Replit
Handle environment variable differences between CI and Replit
Your GitHub Actions workflow runs in a separate environment from Replit, so secrets must be configured in both places. In GitHub, go to repository Settings, then Secrets and variables, then Actions, and add the secrets your tests need (like test API keys or database URLs). In Replit, the same values live in the Secrets panel. For deployment-specific secrets, add them separately in the Replit Deployments pane. Keep a checklist of which secrets exist in which environment to avoid the common problem of tests passing in CI but the app failing in deployment due to missing secrets.
Expected result: Environment variables are configured in GitHub Actions secrets and in the Replit Secrets panel with the correct values for each environment.
Complete working example
1name: CI Pipeline for Replit Project23on:4 push:5 branches: [main]6 pull_request:7 branches: [main]89jobs:10 lint:11 runs-on: ubuntu-latest12 steps:13 - uses: actions/checkout@v414 - uses: actions/setup-node@v415 with:16 node-version: '20'17 cache: 'npm'18 - run: npm ci19 - run: npm run lint2021 test:22 runs-on: ubuntu-latest23 needs: lint24 steps:25 - uses: actions/checkout@v426 - uses: actions/setup-node@v427 with:28 node-version: '20'29 cache: 'npm'30 - run: npm ci31 - run: npm test32 env:33 NODE_ENV: test34 TEST_API_KEY: ${{ secrets.TEST_API_KEY }}3536 notify:37 runs-on: ubuntu-latest38 needs: [lint, test]39 if: github.ref == 'refs/heads/main' && github.event_name == 'push'40 steps:41 - name: Deployment ready notification42 run: echo 'All checks passed. Deploy from Replit workspace.'Common mistakes
Why it's a problem: Expecting Replit to automatically redeploy when GitHub Actions passes
How to avoid: Replit syncs code from GitHub but does not automatically redeploy. After code syncs, you must manually click Publish in the Replit workspace to update the deployment.
Why it's a problem: Using the same API keys in CI and production
How to avoid: Create separate test API keys with limited permissions for CI. Store production keys only in Replit Secrets and deployment secrets.
Why it's a problem: Forgetting to add secrets to GitHub Actions that tests need
How to avoid: Go to your GitHub repository Settings, then Secrets and variables, then Actions. Add all secrets your test suite requires, such as test database URLs or API keys.
Why it's a problem: Editing code in both Replit and GitHub without syncing
How to avoid: Always pull the latest changes before editing. Replit syncs on the main branch, but if you edit in both places simultaneously you may get merge conflicts.
Why it's a problem: Running the full test suite on every commit, slowing down the pipeline
How to avoid: Split your pipeline into fast jobs (lint) and slower jobs (integration tests). Run integration tests only on pull requests to main, not on every commit to feature branches.
Best practices
- Use GitHub branch protection rules to require CI checks before merging to main
- Keep test and lint scripts in package.json so they run the same way locally, in CI, and in Replit Shell
- Use npm ci instead of npm install in GitHub Actions for faster, deterministic installs
- Configure separate secrets in GitHub Actions and Replit since they do not share environment variables
- Start with simple smoke tests and gradually add more comprehensive test coverage
- Use pull request workflows to review code changes before they sync to your Replit deployment
- Add a notification step to alert your team when CI passes and deployment is ready
- Keep your CI workflow fast by caching node_modules and running lint and test jobs in parallel
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I have a Node.js project in Replit connected to GitHub. I want to set up a CI/CD pipeline using GitHub Actions that runs ESLint and Vitest on every pull request, and notifies my team on Slack when tests pass on main. Write the complete GitHub Actions workflow YAML file and explain how to configure the GitHub secrets.
Help me set up automated testing for my project. Create a test file using Vitest that tests my main API endpoints. Then create a .github/workflows/ci.yml file that runs these tests on every push. Also add lint and test scripts to my package.json.
Frequently asked questions
No. Replit does not include native CI/CD pipelines. You can achieve similar results by connecting your Replit project to GitHub and using GitHub Actions for automated testing, linting, and notifications.
Replit automatically syncs code from GitHub to your workspace, but it does not automatically redeploy. You must manually click Publish in the Replit workspace to update a deployment after code changes sync.
No. GitHub Actions runs in its own Ubuntu environment on GitHub's servers. Your tests run in a different environment than Replit, so you need to ensure dependencies and environment variables are configured in both places.
Add secrets to GitHub Actions via your repository Settings under Secrets and variables. Add the same secrets (possibly with different values for test vs production) in the Replit Secrets panel. They do not sync between the two platforms.
Replit's built-in Git integration is designed for GitHub specifically. You can use GitLab by pushing code manually from the Replit Shell using the git CLI and a personal access token stored in Secrets, but the experience is less seamless.
Yes. RapidDev specializes in bridging the gap between Replit's browser-based development and enterprise CI/CD requirements. They can help architect pipelines that include automated testing, staging environments, and deployment automation.
Vitest and Jest both work well for Node.js projects. They run identically in Replit Shell and GitHub Actions. For Python projects, pytest is the standard choice. The key is ensuring your package.json or requirements.txt specifies the exact versions used.
Set up GitHub branch protection rules that require CI checks to pass before merging to main. Since Replit syncs from the main branch, this ensures only tested code reaches your Replit workspace and subsequent deployment.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation