18 Prompts for CI/CD: GitHub Actions, GitLab CI, ArgoCD

# 18 Prompts for CI/CD: GitHub Actions, GitLab CI, ArgoCD\n\n## Introduction\n\nContinuous Integration and Continuous Delivery (CI/CD) pipelines are the backbone of modern DevOps workflows. Whether you are using GitHub Actions, GitLab CI, or ArgoCD, having the right prompts to generate, debug, or optimize your pipeline configurations can save hours of manual work. This curated collection of 18 practical prompts covers common tasks like setting up multi-stage builds, implementing rollback strategies, integrating security scans, and configuring GitOps workflows. Each prompt is designed to be copy-paste ready, with a clear explanation and a working example. By the end of this guide, you will have a reusable toolkit to accelerate your CI/CD automation.\n\n> Note: All prompts below are intended for use with AI assistants (e.g., ChatGPT, Claude) or as templates for manual configuration. Replace placeholders (e.g., your-project, your-registry) with your actual values.\n\n## 1. Generate a GitHub Actions workflow for a Node.js app with linting, tests, and Docker build\n\nTask: Create a complete CI pipeline that runs ESLint, unit tests with Jest, builds a Docker image, and pushes it to Docker Hub.\n\nPrompt:\n\nGenerate a GitHub Actions YAML workflow that:\n- Triggers on push to main branch and pull requests.\n- Sets up Node.js 20.\n- Runs npm ci, npm run lint, npm test.\n- Builds a Docker image tagged with commit SHA and 'latest'.\n- Logs in to Docker Hub using secrets DOCKER_USERNAME and DOCKER_PASSWORD.\n- Pushes the image to Docker Hub under user 'your-dockerhub-user'.\n- Uses caching for node_modules and Docker layers.\n\n\nExample output (.github/workflows/ci.yml):\nyaml\nname: CI Pipeline\n\non:\n push:\n branches: [ main ]\n pull_request:\n branches: [ main ]\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - name: Use Node.js 20\n uses: actions/setup-node@v4\n with:\n node-version: 20\n cache: 'npm'\n - run: npm ci\n - run: npm run lint\n - run: npm test\n - name: Set up Docker Buildx\n uses: docker/setup-buildx-action@v3\n - name: Cache Docker layers\n uses: actions/cache@v4\n with:\n path: /tmp/.buildx-cache\n key: ${{ runner.os }}-buildx-${{ github.sha }}\n restore-keys: |\n ${{ runner.os }}-buildx-\n - name: Login to DockerHub\n uses: docker/login-action@v3\n with:\n username: ${{ secrets.DOCKER_USERNAME }}\n password: ${{ secrets.DOCKER_PASSWORD }}\n - name: Build and push\n uses: docker/build-push-action@v5\n with:\n context: .\n push: true\n tags: your-dockerhub-user/my-app:latest, your-dockerhub-user/my-app:${{ github.sha }}\n cache-from: type=local,src=/tmp/.buildx-cache\n cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max\n\n\n## 2. Generate a GitLab CI pipeline for a Python Flask app with unit tests, Docker build, and deployment to Kubernetes\n\nTask: Build a multi-stage GitLab CI pipeline that runs tests, builds a Docker image, and deploys it to a Kubernetes cluster.\n\nPrompt:\n\nCreate a .gitlab-ci.yml that:\n- Uses python:3.11 image for test stage.\n- Runs pip install -r requirements.txt and pytest.\n- Builds a Docker image using kaniko (no Docker-in-Docker).\n- Pushes the image to GitLab Container Registry.\n- Deploys to a Kubernetes cluster using kubectl with a deployment.yaml file.\n- Includes stages: test, build, deploy.\n- Only runs on main branch.\n\n\nExample output (.gitlab-ci.yml):\n```yaml\nstages:\n - test\n - build\n - deploy\n\ntest:\n stage: test\n image: python:3.11\n script:\n - pip install -r requirements.txt\n - pytest --junitxml=report.xml\n artifacts:\n reports:\n junit: report.xml\n only:\n - main\n\nbuild:\n stage: build\n image:\n name: gcr.io/kaniko-project/executor:v1.9.0-debug\n entrypoint: [\

← All posts

Comments