🎯 Exemplos recomendados
Balanced sample collections from various categories for you to explore
GitHub Actions Samples
Comprehensive CI/CD automation examples including workflows, actions, secrets management, and deployment strategies
⚙️ Node.js CI/CD Pipeline
🟡 intermediate
⭐⭐⭐⭐
Complete Node.js application CI/CD workflow with testing, building, security scanning, and deployment
⏱️ 35 min
🏷️ github-actions, ci-cd, nodejs, automation
Prerequisites:
GitHub Actions basics, Docker, Node.js, CI/CD concepts
name: Node.js CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
release:
types: [ published ]
env:
NODE_VERSION: '18.x'
CACHE_VERSION: 'v1'
jobs:
lint-and-security:
name: Lint and Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
- name: Run security audit
run: npm audit --audit-level=high
test:
name: Test Application
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Upload coverage
uses: codecov/codecov-action@v3
build:
name: Build Application
runs-on: ubuntu-latest
needs: [lint-and-security, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: myapp/nodejs-app:latest
⚙️ Python ML/AI Pipeline
🟡 intermediate
⭐⭐⭐⭐
Complete Python machine learning pipeline with data processing, model training, testing, and deployment
⏱️ 40 min
🏷️ github-actions, ml, python, mlops
Prerequisites:
GitHub Actions, Python, Machine Learning, Docker, MLflow
name: Python ML/AI Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * 1'
env:
PYTHON_VERSION: '3.9'
jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run linting
run: |
black --check .
flake8 .
test:
name: Test Application
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: pytest tests/ --cov=src
- name: Upload coverage
uses: codecov/codecov-action@v3
⚙️ Multi-Platform Build Pipeline
🔴 complex
⭐⭐⭐⭐⭐
Cross-platform CI/CD pipeline for desktop and mobile applications with matrix builds and artifact management
⏱️ 45 min
🏷️ github-actions, multi-platform, release, automation
Prerequisites:
GitHub Actions advanced, Multi-platform development, CI/CD, Release management
name: Multi-Platform Build Pipeline
on:
push:
branches: [ main, develop ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
env:
BUILD_NUMBER: ${{ github.run_number }}
COMMIT_SHA: ${{ github.sha }}
jobs:
configure:
name: Configure Build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
build-matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate version
id: version
run: |
VERSION="1.0.${{ env.BUILD_NUMBER }}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate build matrix
id: matrix
run: |
MATRIX='{"platform": ["windows", "macos", "linux"]}'
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
build:
name: Build - ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
needs: configure
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.configure.outputs.build-matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build application
run: |
npm run build -- --${{ matrix.platform }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.platform }}-${{ env.BUILD_NUMBER }}
path: dist/