CI/CD Cheat Sheet

By Syncfusion®, Inc. · Last updated

Every task from the course side by side for GitHub Actions, Azure Pipelines and GitLab CI, with the lesson that owns each idea.

CI/CD Cheat Sheet

The same task on each platform. Each row links back to the lesson that owns the idea.

Simple lesson: find the task in the left column, copy the line for your platform.

Triggers

TaskGitHub ActionsAzure PipelinesGitLab CI
Run on push to mainon: push: branches: [main]trigger: branches: include: [main]rules: - if: $CI_COMMIT_BRANCH == "main"
Run on pull requestson: pull_requestpr: branches: include: ['*']rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event"
Run at 2 AM UTCschedule: - cron: '0 2 * * *'schedules: - cron: '0 2 * * *'A pipeline schedule in project settings
Run by handworkflow_dispatch:Always onwhen: manual

Owner: Your First Pipeline.

Jobs and Steps

TaskGitHub ActionsAzure PipelinesGitLab CI
Pick the machineruns-on: ubuntu-latestpool: vmImage: ubuntu-latestimage: node:22
Run a commandrun: npm testscript: npm testscript: - npm test
Wait for a jobneeds: builddependsOn: buildneeds: [build]
Time limittimeout-minutes: 15timeoutInMinutes: 15timeout: 15m
Set a valueenv: API_URL: …variables: API_URL: …variables: API_URL: …
Matrixstrategy: matrix: node-version: [20, 22]strategy: matrix: node20: …parallel: matrix: - NODE: ["20", "22"]

Owners: Your First Pipeline, Reading Red Builds, Faster Pipelines.

Speed

TaskGitHub ActionsAzure Pipelines
Cache npmactions/setup-node with cache: npmCache@2 with key from package-lock.json
Cache NuGetactions/setup-dotnet with cache: trueCache@2 with key from packages.lock.json
Cancel old runsconcurrency: + cancel-in-progress: truepr: autoCancel: true

Owner: Faster Pipelines.

Artifacts

TaskGitHub ActionsAzure Pipelines
Save outputactions/upload-artifactPublishPipelineArtifact@1
Get outputactions/download-artifactDownloadPipelineArtifact@2 (automatic in deployment jobs)
Commit SHA${{ github.sha }}$(Build.SourceVersion)
Build number${{ github.run_number }}$(Build.BuildNumber)

Owner: Artifacts and Versions.

Tests and Workflow Logic

TaskGitHub ActionsAzure Pipelines
Publish a test reportdorny/test-reporterPublishTestResults@2
Run after a failure tooif: ${{ !cancelled() }}condition: succeededOrFailed()
Database for testsservices: postgres: image: postgres:17resources: containers: + services:
Pass a value to a job>> "$GITHUB_OUTPUT" + needs.<job>.outputs.<name>##vso[task.setvariable …;isOutput=true] + dependencies.<job>.outputs['<step>.<name>']
Skip docs-only changespaths-ignore: ['**.md']trigger: paths: exclude: ['*.md']

Owner: Tests and Workflow Logic.

Containers

TaskGitHub ActionsAzure Pipelines
Sign in to the registrydocker/login-action with GITHUB_TOKENDocker Registry service connection
Build and pushdocker/build-push-action with push: trueDocker@2 with command: buildAndPush
Tag with the committags: ghcr.io/shop/shop-web:${{ github.sha }}tags: $(Build.SourceVersion)
Cache layerscache-from: type=gha, cache-to: type=gha,mode=maxUse a registry cache image
Scan with a gatetrivy image --exit-code 1 --severity CRITICAL,HIGH …Same command in a script:
Attestactions/attest-build-provenance + attestations: writeNot built in

Owner: Containers in CI.

Security

TaskGitHub ActionsAzure Pipelines
Pin outside codeuses: owner/action@<40-char SHA> # v1.2.3Pin template repos with ref:
Read-only tokenpermissions: contents: readLimit job authorization scope
Fork safetypull_request, not pull_request_targetKeep fork secrets off (default)
No token on diskpersist-credentials: falsepersistCredentials off (default)

Owner: Pipeline Security.

Delivery

TaskGitHub ActionsAzure Pipelines
Use an environmentenvironment: productiondeployment: job with environment: production
OIDC sign-inazure/login + id-token: writeA workload identity service connection
Deploy an imageazure/webapps-deploy with images:AzureWebAppContainer@1 with containers:
Deploy a packageazure/webapps-deploy with package:AzureWebApp@1 with package:
Production on a releaseon: release: types: [published]trigger: tags: include: ['v*']
Roll backdeploy ${{ vars.LAST_GOOD_TAG }}deploy $(LAST_GOOD_TAG)
Main onlyif: github.ref == 'refs/heads/main'condition: … eq(variables['Build.SourceBranch'], 'refs/heads/main')
Run on failureif: failure()condition: failed()
Smoke testrun: curl --fail --retry 5 … /healthscript: curl --fail --retry 5 … /health
Shared templateuses: ./.github/workflows/x.yml- template: templates/x.yml

Owners: Environments and Secrets, Deploy for Real, Deploy and Smoke Test, Rollback and Recovery, Pipelines as a Product.

After the Deploy

TaskGitHub ActionsAzure Pipelines
Message on failureslackapi/slack-github-action + if: failure()curl to the webhook + condition: failed()
Link to the run${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}$(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)
Debug logsACTIONS_STEP_DEBUG: truesystem.debug: true
Windows toomatrix: os: [ubuntu-latest, windows-latest]matrix: with vmImage: $(imageName)

Owner: After the Deploy.

Gitea Actions reads GitHub Actions workflow files, with a few differences. Most of the GitHub column works there too. Check Gitea's documentation for the parts it does not support.

Next: Pipeline Error Messages