Back to cookbook

AI Prompt to Write a GitHub Actions CI/CD Workflow from Plain English

0 views Published

Make this prompt yours

Share

This is a prompt for turning a plain-English description of your build, test, and deploy process into a working GitHub Actions workflow YAML file. It's for developers who know exactly what their pipeline should do (run tests on every pull request, deploy to production on a tag push) but don't want to hand-write the trigger syntax, job dependencies, and action references from scratch.

The prompt works best when you give the model concrete specifics: the language and package manager your project uses, which events should trigger the workflow (push to main, pull request, tag, manual dispatch), and what should happen at each stage. Being explicit about job ordering (lint before test, test before deploy) and about secrets your deploy step needs matters more than any clever wording, since a generated workflow with the wrong trigger or a missing needs: dependency will either never run or run out of order.

This fits any repo moving off manual deploys or ad hoc scripts, and it is also a fast way to prototype a workflow before you refine the caching and matrix-build details yourself. If you are also optimizing a long, verbose prompt like this one for repeated use across many repos, the Token Optimizer can trim it down without losing the specifics that make the generated YAML correct.

Prompt template

Make this prompt yours

prompt-template
332 tokens
Role: You are a DevOps engineer writing a GitHub Actions workflow file. Context: Project type: [LANGUAGE/FRAMEWORK, e.g. Node.js with npm, Python with Poetry] Repository structure notes: [e.g. monorepo with /api and /web folders, single app at root] Runner: [e.g. ubuntu-latest] Task: Write a GitHub Actions workflow (.github/workflows/[FILENAME].yml) that does the following, in this order: 1. Trigger on: [TRIGGER EVENTS, e.g. pull_request to main, push of tags matching v*] 2. Job 1 - [JOB NAME, e.g. lint]: [WHAT IT DOES] 3. Job 2 - [JOB NAME, e.g. test]: [WHAT IT DOES], must run only after Job 1 succeeds 4. Job 3 - [JOB NAME, e.g. deploy]: [WHAT IT DOES], must run only after Job 2 succeeds and only on [CONDITION, e.g. tag pushes to main] Secrets/environment variables needed (reference by name only, do not invent values): [SECRET NAMES, e.g. DEPLOY_TOKEN, AWS_ACCESS_KEY_ID] Constraints: - Pin third-party actions to a specific major version (e.g. actions/checkout@v4) - Use caching for dependencies where the ecosystem supports it - Keep job names and step names descriptive enough to read clearly in the Actions UI Output format: Return the complete YAML file in a fenced code block, followed by a short bullet list explaining what each job does and when it runs.

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
112 tokens
Project type: Node.js with npm, single app at repo root Repository structure notes: standard create-react-app layout, tests in /src Runner: ubuntu-latest Trigger events: pull_request to main, and push of tags matching v* Job 1: lint - run eslint Job 2: test - run npm test, after lint passes Job 3: deploy - build and publish to S3, after test passes, only on tag pushes Secrets needed: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET_NAME

When to use it

  • Setting up CI/CD for a repository that currently has no automated build, test, or deploy pipeline
  • Migrating a manual deploy script or a different CI provider's config into GitHub Actions syntax
  • Adding a new stage, such as linting or a security scan, to an existing workflow without breaking the stages already in place
  • Prototyping a workflow quickly before hand-tuning caching, matrix builds, or environment-specific details

Best practices

  • State the exact trigger events you want (push, pull_request, tags, workflow_dispatch) rather than letting the model guess
  • List job dependencies explicitly, such as "deploy should only run after tests pass on the main branch"
  • Name which secrets or environment variables the workflow needs by name, without pasting their actual values into the prompt
  • Specify the runner OS and language version so the generated actions (like setup-node or setup-python) match your actual project

Common mistakes

  • Leaving out the trigger conditions and getting a workflow that runs on every push when you only wanted it on pull requests
  • Pasting real secret values into the prompt instead of referencing them as GitHub secrets by name
  • Not specifying job order, resulting in a deploy step that can run before tests finish
  • Accepting the generated YAML without checking the action versions it pins, since outdated or unpinned action versions are a common source of pipeline breakage

FAQs

How do I write a GitHub Actions workflow without knowing the exact YAML syntax?

Describe your pipeline in plain English (what should trigger it, what each stage does, and the order stages run in) and ask a model to generate the YAML. Being specific about trigger events and job dependencies matters more than YAML syntax knowledge, since the model handles the syntax.

How do I make a deploy job only run after tests pass?

Use the needs: keyword to make one job depend on another, and add an if: condition if the deploy should also be restricted to certain branches or tags, such as if: startsWith(github.ref, 'refs/tags/v').

Should I paste my actual secret values into the prompt?

No. Reference secrets by name only, such as secrets.AWS_ACCESS_KEY_ID, and store the real values in your repository's Settings > Secrets. A prompt or generated workflow should never contain the literal secret value.

Which Cuelara tool helps me refine a generated workflow prompt before reusing it across repos?

Prompt Optimizer — its Coding mode is built for turning a rough description like this one into a tighter, more structured prompt you can reuse across multiple repositories.

Found this prompt useful? Share it.

Share

More in Code Generation & Software Engineering

Code Generation & Software Engineering

AI Prompt to Debug a Failed Vercel Deployment Using Vercel's MCP Server

This Vercel MCP prompt helps developers and DevOps engineers figure out why a deployment failed without manually scrolling through build log…

ROLE: You are a deployment troubleshooting assistant with access to Vercel's MCP server.

CONTEXT:
- Project: [PROJECT_NAME]
- Framework: [FRAMEWORK, e.g. Next.js 14]
- Deployment ID or URL: [DEPLOYMENT_ID_OR_URL]
- Last known good deployment: [PREVIOUS_DEPLOYMENT_ID_OR_URL, or 'none']
- What changed since the last successful deploy: [RECENT_CHANGES_SUMMARY]

TASK:
1. Retrieve the build and runtime logs for the failing deployment.
2. Identify the failure category: build error, runtime error, environment/configuration issue, or dependency issue.
3. Quote the specific log lines that show the root cause.
4. If a last known good deployment is provided, compare configuration and environment variables between the two.
5. Propose a ranked list of likely fixes, most probable first.

CONSTRAINTS:
- Do not guess at a cause without quoting supporting log evidence.
- Flag if critical information (e.g. an environment variable value) is missing rather than assuming it.

OUTPUT FORMAT:
- Failure category
- Root cause (with quoted log evidence)
- Ranked fix recommendations
- Any missing information needed to confirm the diagnosis

Make this prompt yours

Code Generation & Software Engineering

ChatGPT Prompt to Generate a Production-Ready Dockerfile for Your App

This Dockerfile generator prompt gives ChatGPT, Claude, or Gemini everything needed to write a secure, production ready Dockerfile for your…

You are an expert DevOps engineer who writes secure, production-ready Dockerfiles.

Context:
- Application language and version: [LANGUAGE AND VERSION, e.g., Node.js 20]
- Framework: [FRAMEWORK, e.g., Express, Django, Spring Boot]
- Package manager: [PACKAGE MANAGER, e.g., npm, pip, Maven]
- Target deployment platform: [PLATFORM, e.g., AWS ECS, Kubernetes, linux/amd64]
- Special requirements: [e.g., private package registry, native dependencies, health checks]

Task:
Write a production-ready Dockerfile for this application. Use a multi-stage build that separates the build/dependency-install stage from the final runtime stage. The final image should:
1. Use the smallest reasonable base image for the runtime.
2. Run as a non-root user.
3. Only copy the files needed to run the application, not build tools or source maps.
4. Include a HEALTHCHECK instruction appropriate for this type of service.
5. Set any necessary environment variables and expose the correct port.

Constraints:
- Do not use the "latest" tag for any base image; pin a specific version.
- Keep the final image size as small as possible.
- Explain, in a short comment above each non-obvious instruction, why it's there.

Output format:
1. The complete Dockerfile in a single code block.
2. A short bullet list explaining the base image choice and any trade-offs.
3. One suggested .dockerignore entry list for this stack.

Make this prompt yours

Code Generation & Software Engineering

AI Prompt to Debug a Failing API Test Using Postman's MCP Server

This prompt helps developers and QA engineers debug a failing API test by having an AI assistant like Claude or ChatGPT pull live request an…

ROLE: You are a senior API test engineer helping debug a failing test in a Postman collection accessed through an MCP connection.

CONTEXT:
- Collection name: [COLLECTION_NAME]
- Failing request/folder: [REQUEST_OR_FOLDER_NAME]
- Environment: [ENVIRONMENT_NAME]
- Last known good run (if available): [RUN_ID_OR_DATE]

TASK:
1. Retrieve the failing request's details (method, URL, headers, body) and its actual response (status code, headers, body) from the connected Postman MCP server.
2. Identify the exact assertion or test script line that failed, quoting it directly.
3. Compare the failing response against the expected response or the last known good run, and list every meaningful difference.
4. Classify the likely root cause as one of: schema change, authentication/authorization failure, timeout/network issue, environment misconfiguration, or application bug.
5. Propose a specific fix or next diagnostic step for that category.

CONSTRAINTS:
- Do not guess at response data you have not actually retrieved; if the MCP call fails, say so explicitly.
- Keep the explanation under 200 words before listing the fix.

OUTPUT FORMAT:
- Summary: [one-sentence description of the failure]
- Evidence: [key request/response fields and the failing assertion]
- Root cause category: [one of the five categories above]
- Recommended fix: [specific, actionable step]

Make this prompt yours