Skip to content

Latest commit

 

History

History
122 lines (92 loc) · 6.3 KB

CiCD_tools.md

File metadata and controls

122 lines (92 loc) · 6.3 KB

Basic comparison of CI/CD YAML steps for Azure DevOps YAML, GitHub Actions YAML, and GitLab CI/CD YAML

StepAzure DevOps YAMLGitHub Actions YAMLGitLab CI/CD YAML
**Checkout Source Code**`checkout``checkout``git clone`
**Build**`task: Build``run: npm build` or `run: make``script: - make build` or `script: - npm run build`
**Test**`task: Test``run: npm test` or `run: make test``script: - make test` or `script: - npm run test`
**Deploy**`task: Deploy``run: npm deploy` or custom deployment task`script: - make deploy` or custom deployment task
**Artifact Publish**`publish: Artifact``upload-artifact``artifacts: paths:`
**Environment Setup**`task: Setup Environment`Custom environment setup steps`before_script:` or `script:` with setup commands
**Notification**`task: Send Notification`Notifications in workflow or custom notification steps`notify:` or `when: manual` for manual approval steps
**Conditional Steps**`condition: expression``if: condition``rules:`
**Docker Build/Push**`task: Docker``build-push` with Docker actions`script: - docker build -t myimage .` and `script: - docker push myimage`
This table provides a high-level comparison of common CI/CD steps. Note that each platform has its own specific syntax and features. It's crucial to refer to the official documentation for the most accurate and up-to-date information.

** Building and deploying a Node.js application as an example for each CI/CD tool**

Azure DevOps YAML:

# File: azure-pipeline.yml

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

jobs:
- job: BuildAndDeploy
  steps:
  - checkout: self

  - task: NodeTool@0
    inputs:
      versionSpec: '14.x'
    displayName: 'Install Node.js'

  - script: |
      npm install
      npm run build
    displayName: 'Build Application'

  - task: AzureRmWebAppDeployment@4
    inputs:
      ConnectionType: 'AzureRM'
      azureSubscription: 'YourAzureServiceConnection'
      appType: 'webAppLinux'
      WebAppName: 'YourWebAppName'
      packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

Replace 'YourAzureServiceConnection' and 'YourWebAppName' with your actual Azure service connection name and web application name.

GitHub Actions YAML:

# File: github-actions.yml

name: Build and Deploy

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Repository
      uses: actions/checkout@v2

    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '14'

    - name: Install Dependencies
      run: npm install

    - name: Build Application
      run: npm run build

    - name: Deploy to Azure Web App
      uses: azure/webapps-deploy@v2
      with:
        app-name: 'YourWebAppName'
        slot-name: 'production'
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
        package: .

Replace 'YourWebAppName' with your actual web application name. Make sure to set up the AZURE_WEBAPP_PUBLISH_PROFILE secret in your GitHub repository with the Azure publish profile.

GitLab CI/CD YAML:

# File: .gitlab-ci.yml

stages:
  - build
  - deploy

variables:
  NODE_VERSION: "14"

before_script:
  - apt-get update -qy
  - apt-get install -y nodejs
  - npm install

build:
  stage: build
  script:
    - npm run build
  tags:
    - custom-runner

deploy:
  stage: deploy
  script:
    - echo "Deploy to Azure Web App"
    # Add your deployment script or commands here
  tags:
    - custom-runner

In this GitLab CI/CD example, you might need to customize the deployment script based on your requirements.

Remember to adapt these examples to your specific project structure and requirements. Also, ensure that you have the necessary permissions and configurations for each CI/CD platform.