Automate testing and deployment with a GitHub Actions workflow.
GitHub Actions runs workflows defined in YAML files under .github/workflows/
whenever an event (like a push or pull request) fires.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
Gate the deploy job on the branch so pull requests only run tests:
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: npm run deploy
Store deployment credentials in the repository's Settings β Secrets and
reference them as ${{ secrets.MY_SECRET }} β never commit them to the
workflow file.
See DevOps as one feedback loop, then practise the tools in the order they become useful.
DevOps is a feedback-oriented way of delivering and operating software, not a job title or toolchain. Product, development, security, and operations share responsibility from planning through production learning.
The command line becomes safer when you always know the current directory, preview targets, quote paths, read help, and prefer reversible operations. Commands compose through files, streams, pipes, and exit codes.