GitHub Actions and CI/CD AutomationLesson 5.4
Continuous Deployment: Automating Deployments
CD workflow, deploy on push, GitHub Pages deployment, Vercel deployment, Docker build and push, deployment environments, rollback
Continuous Deployment: Automating Deployments
Continuous Deployment (CD) extends CI by automatically deploying your application after all checks pass. GitHub Actions integrates with virtually every major hosting platform.
Deploying to GitHub Pages
name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: './dist'
- id: deployment
uses: actions/deploy-pages@v4Building and Pushing Docker Images
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: username/app:latestDeployment Gates
A common CD pattern is to require the CI workflow to pass before deployment starts. Use the needs keyword to create job dependencies:
jobs:
test:
runs-on: ubuntu-latest
steps: [...]
deploy:
needs: test
runs-on: ubuntu-latest
steps: [...]The deploy job only starts if the test job succeeds.
