8 Proven Prompts for Mastering CI/CD Pipelines (GitHub Actions, GitLab CI, ArgoCD)

Introduction

Setting up a reliable CI/CD pipeline is crucial for modern software delivery, but writing configurations from scratch for each tool can be time‑consuming. Whether you use GitHub Actions, GitLab CI/CD, or ArgoCD, having a set of proven prompts (templates) accelerates your workflow and reduces errors. This article collects eight battle‑tested configuration snippets that you can drop into your projects today. Each prompt is complete with a real‑world use case and the exact YAML code.

Tool Comparison at a Glance

Tool Primary Use Strengths Weaknesses
GitHub Actions CI/CD for GitHub repositories Tight GitHub integration; huge marketplace Limited to GitHub; YAML can get verbose
GitLab CI/CD Built‑in CI for GitLab Single application for SCM + CI/CD; auto‑scaling runners Learning curve for advanced features
ArgoCD Kubernetes deployment (CD) Declarative GitOps; supports multi‑cluster Requires Kubernetes expertise

1. Automated Unit Tests (GitHub Actions)

Task: Run tests on every push and pull request.
Prompt: Paste into .github/workflows/test.yml.

name: Unit Tests
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm ci
      - run: npm test

Result: Tests start automatically, and the status is reported on PRs.

2. Docker Build and Push (GitLab CI)

Task: Build a Docker image and push to GitLab Container Registry.
Prompt: Add to .gitlab-ci.yml.

image: docker:latest
services:
  - docker:dind
variables:
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA

stages:
  - build

build_image:
  stage: build
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $IMAGE_TAG .
    - docker push $IMAGE_TAG

Result: Every commit on the default branch produces a versioned Docker image.

3. Blue‑Green Deployment (ArgoCD)

Task: Deploy a new version with zero downtime using a blue‑green strategy.
Prompt: Define an ArgoCD Application and a Service that switches traffic.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp-bluegreen
spec:
  project: default
  source:
    repoURL: 'https://github.com/example/myapp.git'
    path: k8s/overlays/bluegreen
    targetRevision: HEAD
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: production
  syncPolicy:
    automated:
      prune: true

Result: ArgoCD monitors the Git repo and applies the blue‑green manifests, switching the Service selector between color: blue and color: green.

4. Linting & Code Quality (GitHub Actions)

Task: Enforce code style with ESLint and Prettier.
Prompt: Use the Super‑Linter action.

name: Lint
on: pull_request
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: github/super-linter@v5
        env:
          VALIDATE_ALL_CODEBASE: false
          DEFAULT_BRANCH: main
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Result: PRs that violate linting rules are blocked until fixed.

5. Dependency Scanning (GitLab CI)

Task: Check for known vulnerabilities in dependencies.
Prompt: Enable the dependency scanning template.

include:
  - template: Security/Dependency-Scanning.gitlab-ci.yml

dependency_scanning:
  stage: test
  variables:
    DS_DEFAULT_ANALYZERS: "gemnasium-maven,gemnasium-python,gemnasium-npm"

Result: A security report is generated and shown in merge requests.

6. Scheduled Backup Job (GitHub Actions)

Task: Run a database backup every day at midnight.
Prompt: Use cron schedule.

name: Nightly Backup
on:
  schedule:
    - cron: '0 0 * * *'
jobs:
  backup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: |
          pg_dump -h $DB_HOST -U $DB_USER $DB_NAME > backup.sql
          aws s3 cp backup.sql s3://my-backups/$(date +%F).sql
        env:
          DB_HOST: ${{ secrets.DB_HOST }}
          DB_USER: ${{ secrets.DB_USER }}
          DB_NAME: ${{ secrets.DB_NAME }}

Result: Daily backups stored in S3.

7. Self‑Hosted Runner (GitLab CI)

Task: Register a runner on an EC2 instance for more control.
Prompt: Use the GitLab Runner Helm chart.

# values.yaml for helm install gitlab-runner -f values.yaml
gitlabUrl: https://gitlab.example.com
runnerRegistrationToken: "<YOUR_TOKEN>"
rbac:
  create: true
runners:
  privileged: true
  tags: "self-hosted"

Result: A runner is registered and picks up tagged jobs.

8. Canary Release with ArgoCD Rollouts

Task: Gradually shift traffic to a new version using a canary analysis.
Prompt: Define a Rollout with traffic routing.

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: myapp-canary
spec:
  replicas: 10
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: myapp
          image: myapp:latest
  strategy:
    canary:
      steps:
        - setWeight: 20
        - pause: {duration: 2m}
        - setWeight: 40
        - pause: {duration: 2m}
        - setWeight: 60
        - pause: {duration: 2m}
        - setWeight: 80
        - pause: {duration: 2m}

Result: ArgoCD Rollouts intelligently shifts traffic; if metrics fail, it rolls back automatically.

Conclusion

These eight prompts cover the most common CI/CD tasks across three major platforms. By using them as a starting point, you can avoid repetitive boilerplate and focus on your unique business logic. Each snippet is production‑ready but should be customized (e.g., adjusting node-version, image names, secrets). Keep this collection handy—or feed it to your AI assistant to generate variations tailored to your stack. Happy shipping!

← All posts

Comments