Problem Statement
Walk through a minimal pipeline definition for a web service.
Explanation
Start with triggers on push and pull requests. Add a build step to install dependencies and create the artifact. Run unit tests and linters. On main branch, publish the artifact and deploy to a staging env with health checks.
Keep jobs short and independent. Cache dependencies and fail fast on basic checks before heavier steps.
Code Solution
SolutionRead Only
name: ci on: [push, pull_request] jobs: build_test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm ci - run: npm run lint - run: npm test -- --ci deploy_staging: needs: build_test if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - run: echo Deploying artifact to staging
