A reliable CI/CD pipeline turns a tested code change into a repeatable release instead of a manual sequence of commands. This guide explains how to set up an app CI/CD workflow for web and mobile projects, from pull-request validation and dependency installation through preview deployments, production releases, staged rollout, and rollback decisions.
Overview
A CI/CD pipeline is an automated path between a repository event and a deployable application. Continuous integration (CI) checks whether a change can be safely merged. Continuous delivery or deployment (CD) packages that change and moves it toward users, either with a manual approval step or automatically.
The exact syntax differs between CI providers, but the design is broadly portable. A practical pipeline for a web or mobile app commonly includes these stages:
- Trigger: Start validation when a pull request is opened or updated, and start a release workflow when approved code reaches the designated release branch or tag.
- Install: Select the required runtime, install locked dependencies, and cache only files that are safe to reuse.
- Validate: Run formatting checks, linting, type checks, unit tests, and any required security or dependency checks.
- Build: Create the web bundle, server package, container image, or mobile binary using a reproducible command.
- Verify: Run integration, smoke, database, or API checks against an appropriate test environment.
- Release: Store the build artifact, deploy to a preview or staging environment, and promote the same verified artifact to production.
- Observe and recover: Confirm that the release is healthy and define the conditions for pausing or rolling back.
Keep pull-request validation separate from production deployment. This makes feedback fast for contributors while reserving credentials, approvals, and release operations for a controlled workflow. If you are deploying a full-stack application, document environment variables and preview environments alongside the pipeline rather than hiding them in provider-specific settings. The guide Deploy a Full-Stack App with Environment Variables, Secrets, and Preview Environments provides a useful companion checklist.
Checklist by scenario
For every pull request
- Define the supported runtime and package-manager versions in the repository or pipeline configuration.
- Install from the lockfile with the package manager's reproducible or frozen-lockfile option where appropriate.
- Run formatting, linting, type checks, and unit tests as separate steps so failures are easy to locate.
- Build the application before merge when a successful build is required for deployment.
- Upload test reports or logs when the CI system supports artifacts, especially for failed jobs.
- Cancel superseded runs for the same branch when parallel execution could waste capacity or create confusing previews.
- Prevent merges when required checks fail, while allowing maintainers to rerun transient infrastructure failures.
For a web application or API
- Build once and identify the resulting artifact with a commit, tag, or other immutable identifier.
- Deploy pull requests to isolated preview environments when reviewers need to inspect behavior in a browser.
- Run API smoke tests against staging with test credentials and test data. For request, authentication, error, and regression coverage, see API Testing Workflow for New Apps.
- Check database migrations before deployment. Confirm that the migration is compatible with the currently running application during a rolling release.
- Keep production secrets outside the repository and expose only the variables required by each job.
- Deploy to staging first, then require an explicit approval or protected release condition before production.
- Run a post-deployment health check against the public endpoint and a small number of critical user paths.
For a mobile application
- Separate fast pull-request checks from the slower build and signing workflow.
- Pin the mobile SDK, runtime, build tools, and dependency versions that the project supports.
- Store signing certificates, provisioning profiles, keystores, and passwords in the CI provider's protected secret or file store.
- Use temporary or restricted credentials where the platform permits it, and limit which branches can access signing material.
- Build unsigned artifacts for routine validation when signing is not needed, then sign only in the release job.
- Retain the generated package and its metadata so a release can be audited or reproduced from the same commit.
- Test the release configuration, not only the debug configuration; environment flags and permissions can differ.
For a small team establishing its first pipeline
Start with one required pull-request workflow and one manually approved production workflow. Add preview deployments, integration tests, scheduled maintenance jobs, and staged releases after the basic path is dependable. A minimal pipeline that fails clearly is more useful than a large configuration nobody can maintain.
Reusable release-pipeline template
The following provider-neutral outline separates validation from release. Replace the commands and environment names with those used by your stack:
pull_request:
- checkout repository
- select pinned runtime
- install locked dependencies
- run format check
- run lint and type check
- run unit tests
- build application
- publish logs and test reports
release:
trigger: protected release branch or version tag
permissions: minimum required for deployment
- checkout exact release commit
- install locked dependencies
- build immutable artifact
- run integration and database compatibility checks
- deploy to staging or preview
- run smoke tests
- require approval when configured
- promote the same artifact to production
- run health checks
- record release identifier and rollback target
What to double-check
Secrets and permissions
Inventory every credential used by the workflow: package registries, cloud deployment, databases, mobile signing, monitoring, and app-store operations. Mark which jobs need each secret. A pull-request job that runs untrusted code should not automatically receive production credentials. Avoid printing environment variables in logs, and review permissions whenever a new action, plugin, or service is added.
Runtime and dependency consistency
Make local development, CI, staging, and production use compatible runtime versions. A dependency update can change the lockfile, build output, or test behavior, so review updates deliberately rather than allowing the pipeline to resolve a moving range. For a focused maintenance process, use How to Update npm Dependencies Safely. Also confirm that the selected runner image still contains the SDKs and system packages your build needs.
Artifacts and deployment identity
Decide what is stored after a build: web assets, container references, mobile packages, source maps, test reports, and release metadata. Give each artifact a traceable identity, such as a commit or release tag. Prefer promoting the artifact that passed staging rather than rebuilding from the same source later; rebuilding can introduce differences in dependencies or tooling.
Database changes and rollback boundaries
A code rollback does not automatically undo a database migration. Use backward-compatible changes where possible: add new fields before using them, support old and new application versions during rollout, and remove obsolete structures only after the newer code is established. Write down whether each migration is reversible, forward-fixable, or requires a recovery procedure.
Release health signals
Choose a small set of signals that can stop a rollout: failed health checks, elevated application errors, broken authentication, unavailable critical endpoints, or a failed mobile build verification. Define who can pause a deployment and where the relevant logs are located. The Production Readiness Checklist for Launching and Updating a Cloud App can help connect pipeline checks with wider operational readiness.
Common mistakes
- Testing only after deployment: Run fast checks before merge so obvious failures do not reach a shared environment.
- Using floating tool versions: Unpinned runtimes and dependencies can make a previously successful build fail without a code change.
- Rebuilding during promotion: Generate a versioned artifact once, then promote that artifact through environments.
- Putting secrets in repository files: Use the CI provider's protected secret mechanism and rotate credentials when access changes.
- Making every job sequential: Run independent checks in parallel, then collect them at a clear gate before building or releasing.
- Ignoring failed cleanup: Preview environments, caches, and artifacts can consume resources or expose stale data if their lifecycle is undefined.
- Relying on a single rollback button: Confirm that the previous artifact, configuration, database state, and external services are all compatible with recovery.
- Allowing mobile signing in routine jobs: Keep high-value signing material out of ordinary pull-request validation whenever possible.
- Adding automation without ownership: Every scheduled check, deployment target, and secret should have a maintainer and a documented failure path.
When to revisit
Review the pipeline before seasonal planning cycles and whenever the workflow or its supporting tools change. At minimum, perform a focused review twice a year, and perform an immediate review after a major runtime, mobile SDK, CI provider, deployment platform, repository, or security change. Do not treat that interval as a guarantee that a provider's syntax or usage limits remain unchanged; verify current documentation before editing configuration.
Use this trigger list to decide what to inspect:
- Adding a service: update dependency installation, environment variables, health checks, permissions, and artifact handling.
- Changing branches or release strategy: inspect triggers, protection rules, approvals, preview naming, and production access.
- Upgrading runtimes or SDKs: test locally and in CI, then update pinned images and compatibility notes together.
- Troubleshooting failed builds: compare the failing job with the last successful artifact, inspect cache behavior, and verify runner capabilities before changing application code.
- Tightening release controls: reduce permissions, review secret exposure, add required approvals, and document emergency access.
- Preparing a larger release: rehearse rollback, confirm database compatibility, check artifact retention, and verify that alerts and ownership are current.
Before your next release, copy the template into the project documentation and mark each item as automated, manually verified, or not applicable. Then run one intentionally small change through the complete path: pull request, build, preview or staging, approval, production deployment, health check, and rollback review. That exercise exposes missing permissions and unclear ownership before a higher-risk release depends on them.