title | author | format | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Continuous Integration and Continuous Delivery |
Vladimir Lelicanin - SAE Institute |
|
- Continuous Integration (CI) is a practice of integrating code changes into a shared repository frequently
- CI ensures that each code change is verified by an automated build and automated tests
- Early detection of defects
- Faster feedback loop
- Ability to deliver code changes faster
- Github Actions is a CI/CD tool that allows you to automate your software development workflows
- Actions are individual tasks that can be combined to create a workflow
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
- The workflow is triggered by a push or pull request event
- The workflow runs on an ubuntu-latest runner
- The steps checkout the repository, install dependencies, and run tests
- Continuous Delivery (CD) is a practice of automating the software delivery process
- CD ensures that your software is always in a deployable state
- Github Actions can be used for Continuous Delivery by deploying to a production environment after the CI tests pass
name: CD
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install Dependencies
run: npm install
- name: Build App
run: npm build
- name: Deploy to Production
uses: appleboy/[email protected]
with:
host: ${{ secrets.PROD_SERVER }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/production
git pull origin main
npm install --production
pm2 restart app
- The workflow is triggered by a push event to main branch
- The workflow runs on an ubuntu-latest runner
- The steps checkout the repository, install dependencies, build the app, and deploy to production using SSH
- The Github Actions marketplace contains actions that are created and shared by the community
- These actions can be used as building blocks to create your own workflows
name: Sentry Release
on:
push:
branches:
- master
jobs:
sentry-release:
name: Sentry Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: getsentry/action-release@v1
id: sentry_release
with:
version: ${{ github.sha }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
- The action is triggered by a push event to the master branch
- The steps checkout the repository and use the Sentry Release action to create a new release on Sentry
- Github Actions Documentation
- Continuous Integration Best Practices
- Continuous Delivery Best Practices
- Continuous Integration and Continuous Delivery are critical components of modern software development
- Github Actions provides an easy way to automate your development workflows