PromptAIPromptAI
DemoPricingCommunityBlogPromptsLog inGet Started
Prompt library/Coding

GitHub Actions Prompt for CI Workflows That Pass

A structured prompt that writes a GitHub Actions workflow — triggers, caching, matrix builds — with a real example YAML you can adapt.

Enhanced prompt — ready to use
ROLE
You are a senior DevOps engineer with expertise in continuous integration and GitHub Actions. Your goal is to create an efficient, maintainable GitHub Actions workflow that runs the user's test suite reliably.

TASK
Write a complete GitHub Actions workflow configuration file that automates running the user's tests upon code changes. Think through this step by step, considering typical project structures and best practices for test automation. Include triggering conditions, environment setup, and test execution commands.

CONTEXT
The user needs a GitHub Actions workflow to run tests for their project. The audience is developers who will use this workflow in their repository. The workflow should be general enough to apply to common test scenarios but can assume a typical Node.js, Python, or similar environment if not specified.

REQUIREMENTS
- Create a valid YAML workflow file for GitHub Actions.
- Include triggers for relevant events such as push and pull request to main branches.
- Set up the environment with necessary dependencies before running tests.
- Run test commands appropriate for a common testing framework (e.g., npm test, pytest).
- Think step by step. Consider edge cases such as caching dependencies or handling failures gracefully.
- Before finalizing, verify the syntax and correctness of the workflow configuration.

OUTPUT FORMAT
Provide the full GitHub Actions workflow YAML file content with clear comments explaining each step.

That's what PromptAI produced from this vague prompt: “write a github actions workflow to run my tests”

Example result

```yaml
name: Run Tests

# Trigger workflow on push or pull request events to main or master branches
on:
  push:
    branches:
      - main
      - master
  pull_request:
    branches:
      - main
      - master

jobs:
  test:
    # Use the latest Ubuntu runner for a clean Linux environment
    runs-on: ubuntu-latest

    # Use a matrix strategy to test both Node.js and Python projects in case both exist
    # This makes the workflow flexible and faster when multiple environments need testing.
    strategy:
      matrix:
        language: [node, python]

    steps:
      # Checkout the repository code so we can run tests on it
      - name: Checkout repository
        uses: actions/checkout@v4

      # Setup Node.js environment, caching npm dependencies
      - name: Set up Node.js (only for node matrix)
        if: matrix.language == 'node'
        uses: actions/setup-node@v3
        with:
          node-version: '16'     # Use LTS version or specify project version here
          cache: 'npm'          # Automatically cache ~/.npm directory

      # Install Node.js dependencies and run tests
      - name: Install Node.js dependencies and run tests
        if: matrix.language == 'node'
        run: |
          npm ci              # clean install to ensure fresh deps, faster for CI
          npm test            # assumes test script exists in package.json

      # Setup Python environment and cache pip dependencies
      - name: Set up Python (only for python matrix)
        if: matrix.language == 'python'
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'  # Use specific version, adjust as needed

      - name: Cache pip dependencies (only for python matrix)
        if: matrix.language == 'python'
        uses: actions/cache@v3
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      # Install Python dependencies and run tests
      - name: Install Python dependencies and run tests
        if: matrix.language == 'python'
        run: |
          python -m pip install --upgrade pip
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
          # Run tests: assumes pytest or a test command defined in some way
          # You may need to adjust this line depending on your project
          pytest --maxfail=3 --disable-warnings -q

      # Optional: Upload test results for better visibility (example for pytest)
      - name: Upload test results (Python only)
        if: matrix.language == 'python'
        uses: actions/upload-artifact@v3
        with:
          name: pytest-results
          path: tests/results.xml
        # Note: Ensure your pytest command generates test reports (e.g., pytest --junitxml=tests/results.xml)

      # Optional: Post a summary comment on PR with test results or status could be added as extra enhancement.
```
---

### Explanation of the Workflow:

- **Triggers**: Runs on `push` and `pull_request` events targeting `main` or `master` branches. This covers typical code change events.
- **Matrix Strategy**: Allows running tests for Node.js and Python environments independently, useful if your repo contains either or both types of code/tests.
- **Checkout Action**: Fetches the latest repo code.
- **Node.js Setup**:
  - Uses `actions/setup-node` with caching enabled for npm dependencies to optimize build time.
  - Runs `npm ci` to install dependencies cleanly and then `npm test` which assumes the user has defined a `test` script in `package.json`.
- **Python Setup**:
  - Uses the latest stable Python 3.x version setup.
  - Caches `~/.cache/pip` folder to speed up dependency installation.
  - Installs dependencies from `requirements.txt` if present.
  - Runs `pytest` with options to limit test failures reported and silence warnings for cleaner logs.
- **Test Result Upload (Optional for Python)**:
  - Demonstrates how to upload test artifacts, e.g. test result XML files. This requires extra configuration on `pytest` to output such files.

### Next Steps for the User:

- Adjust Node.js and Python versions according to your project.
- For Node.js: Ensure `npm test` is configured properly.
- For Python: Ensure `pytest` is installed and optionally configure `pytest` to generate report files if you want artifact uploads.
- Extend or modify this workflow if you use other languages or custom testing frameworks.

This approach balances flexibility, caching for performance, and good defaults for most common JavaScript and Python test setups.

How to adapt it

  • •State your language, package manager, and test command for a runnable first draft.
  • •Ask for dependency caching up front — it's the difference between 40s and 4min CI.

Have your own rough prompt? Enhance it into a structured prompt like this in one click.

Enhance your own prompt

Or use the ChatGPT prompt enhancer right inside ChatGPT, or the prompt enhancer for Claude Code in your terminal.

More coding prompts

Pull Request Description Prompt Reviewers Thank You For
A structured prompt that writes a PR description from your diff summary — what changed, why, how to test, and risks — with a real example.
React Component Prompt for Production Components
A structured prompt that writes a typed, accessible React component with props, states, and edge cases handled — with a real example.
System Design Prompt for Architecture Decisions
A structured prompt that produces a system design — components, data flow, storage, and trade-offs — instead of a vague architecture chat.
Web Scraping Prompt for Working Python Scrapers
A structured prompt that writes a Python scraper with selectors, pagination, and polite rate limits — plus a real example script.
API Documentation Prompt for Clear Docs
A structured prompt that documents your API endpoint — params, responses, errors, and examples — in clean reference style, with a real example.
Bash Script Prompt for Shell Automation
A structured prompt that writes a safe, portable Bash script for your task — with checks, comments, and a real example output.
PromptAIPromptAI

Transform your ideas into powerful, structured prompts with AI.

Product

  • Try Demo
  • Pricing
  • Chrome Extension
  • Blog
  • Prompts

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Service
Tools
Prompt Enhancer·ChatGPT Prompt Enhancer·ChatGPT Prompt Generator
For Devs
Prompt Enhancer for Cursor·Prompt Enhancer for Claude Code
Compare
AIPRM Alternative·PromptPerfect Alternative

© 2026 PromptAI. All rights reserved.