CI/CD Pipelines for screenly/playground

Continuous integration and deployment processes used in the project, including automated testing, building, and deployment of Edge Apps.

What is CI/CD Pipelines?

CI/CD pipelines refer to the continuous integration and continuous delivery or deployment processes used by development teams to automate the building, testing, and deployment of their code. This approach enables teams to frequently deliver updates to their applications, while also ensuring that the codebase remains stable and free of errors.

Why is CI/CD Pipelines important?

CI/CD pipelines are important for several reasons:

  1. Faster time to market: By automating the build, test, and deployment processes, teams can release updates more frequently, reducing the time it takes to get new features into the hands of users.
  2. Improved code quality: CI/CD pipelines include automated testing, which helps to catch bugs and errors early in the development process, reducing the likelihood of issues making it into production.
  3. Consistency: CI/CD pipelines ensure that the same build and deployment processes are used for every release, reducing the risk of inconsistencies and errors.
  4. Reduced manual effort: Automating the build, test, and deployment processes reduces the amount of manual effort required, freeing up developers to focus on other tasks.

Implementation of CI/CD Pipelines for screenly/playground

Tools and Services

The following tools and services are used in the implementation of CI/CD pipelines for the screenly/playground project:

  • GitHub: The project is hosted on GitHub, which provides the source control management system and the platform for the CI/CD workflows.
  • GitHub Actions: GitHub Actions is used for the continuous integration and continuous delivery workflows, including building, testing, and deploying the Edge Apps.
  • Docker: Docker is used to create and manage containers for the build and deployment environments.
  • Google Cloud Platform: Google Cloud Platform is used for hosting the Edge Apps and managing the infrastructure.

Workflows

The following workflows are used in the implementation of CI/CD pipelines for the screenly/playground project:

Continuous Integration

The continuous integration workflow is triggered whenever a new commit is pushed to the main branch. The workflow builds the Edge App using Docker, runs the tests, and if successful, creates a new release tag.

name: CI
          on:
            push:
              branches: [ main ]
          jobs:
            build:
              runs-on: ubuntu-latest
              steps:
                - uses: actions/checkout@v2
                - name: Use Docker
                  uses: actions/setup-docker@v1
                - name: Build and Test
                  run: |
                    docker build -t my-app .
                    docker run my-app lint
                    docker run my-app test
                - name: Create Release Tag
                  if: success()
                  uses: actions/create-release@v1
                  with:
                    tag_name: ${{ github.sha }}
                    release_name: ${{ github.ref }}
                    draft: false
          

Continuous Delivery

The continuous delivery workflow is triggered whenever a new release tag is created. The workflow builds the Edge App using Docker, runs the tests, and if successful, deploys the app to Google Cloud Platform.

name: CD
          on:
            release:
              types: [created]
          jobs:
            build:
              runs-on: ubuntu-latest
              steps:
                - uses: actions/checkout@v2
                - name: Use Docker
                  uses: actions/setup-docker@v1
                - name: Build and Test
                  run: |
                    docker build -t my-app .
                    docker run my-app lint
                    docker run my-app test
                - name: Deploy to Google Cloud Platform
                  uses: actions/deploy@v1
                  with:
                    provider:
                      name: google
                      project_id: my-project-id
                      service_account_key: ${{ secrets.GCP_SA_KEY }}
                      application_default_credentials: true
                    config:
                      branch: main
                      app: my-app
                      region: us-central1
                      environment:
                        NODE_ENV: production
          
References