Pipeline CI/CD con GitHub Actions
Automatizzate test e distribuzione della vostra app Node.js creando una pipeline di integrazione e distribuzione continue con GitHub Actions.
Pipeline CI/CD con GitHub Actions è una lezione Node.js Backend Development Bootcamp gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Node.js Backend Development Bootcamp, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Node.js Backend Development Bootcamp include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
What is CI/CD?
Continuous Integration (CI) automatically builds and tests your code on every push. Continuous Delivery/Deployment (CD) automatically ships passing code to production.
Together they catch bugs early and remove manual, error-prone release steps.
Why GitHub Actions?
GitHub Actions runs workflows directly in your repository. There is no separate server to manage, it integrates with pull requests, and it has a generous free tier for public repos.
Workflow File Location
Workflows are YAML files inside .github/workflows/. Each file describes one workflow, and a repo can have many.
// .github/workflows/ci.ymlTriggers
The on key defines what starts a workflow. Common triggers are pushes and pull requests to specific branches.
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]Jobs and Runners
A workflow has one or more jobs. Each job runs on a fresh virtual machine (a runner) you select with runs-on.
jobs:
test:
runs-on: ubuntu-latestSteps
A job is a sequence of steps. A step either runs a shell command (run) or uses a prebuilt action (uses).
steps:
- uses: actions/checkout@v4
- run: echo 'Code checked out'Setting Up Node.js
The official setup-node action installs the Node version you specify and can cache dependencies for faster runs.
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npmInstalling and Testing
With Node ready, install dependencies and run your test suite. If tests fail the job fails, blocking the merge.
- run: npm ci
- run: npm testA Complete CI Workflow
Here is a full, minimal pipeline that checks out code, sets up Node, installs, and tests on every push and pull request.
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npm testSecrets
Never commit API keys. Store them in your repo's Settings > Secrets and reference them with the secrets context. They are masked in logs.
- run: ./deploy.sh
env:
API_KEY: ${{ secrets.API_KEY }}Adding a Deploy Step
For CD, add a job that runs only after tests pass and only on the main branch, then deploys. The needs and if keys control ordering and conditions.
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: echo 'Deploying...'Quick Check
Test your CI/CD knowledge.
Recap
You built an automated pipeline with GitHub Actions:
- Workflows live in
.github/workflows/as YAML onsets triggers;jobsrun onruns-onrunners- Steps use prebuilt actions or run shell commands
- Install with
npm ciand runnpm testautomatically - Store credentials in secrets and gate deploys with
needs+if
Now every push is tested and safe code can ship automatically.
Domande Frequenti
La lezione «Pipeline CI/CD con GitHub Actions» è gratuita?
Sì — il testo completo di «Pipeline CI/CD con GitHub Actions» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Node.js Backend Development Bootcamp, passa a CoddyKit PRO. Il corso Node.js Backend Development Bootcamp include 4 lezioni in totale.
Cosa imparerò in «Pipeline CI/CD con GitHub Actions»?
Automatizzate test e distribuzione della vostra app Node.js creando una pipeline di integrazione e distribuzione continue con GitHub Actions. Eserciti Node.js Backend Development Bootcamp con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Node.js Backend Development Bootcamp?
Non è richiesta alcuna esperienza precedente. Node.js Backend Development Bootcamp su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Pipeline CI/CD con GitHub Actions»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Node.js Backend Development Bootcamp?
Sì. Ogni lezione Node.js Backend Development Bootcamp include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Containerizzazione con Docker
- Distribuzione nel cloud (AWS/Heroku)
- Gestione dei processi con PM2
- Pipeline CI/CD con GitHub Actions