“How can I configure a CI/CD pipeline using YAML to trigger a build only when changes are made to the ‘x’ folder in the ‘development’ branch, and run a simple script (e.g., echo hi)? Can someone provide a working example?”
Sure! Below is an example of how you can configure a CI/CD pipeline using YAML to:
- Trigger only on the
development
branch. - Run only when changes are made to the
x/
folder. - Run a simple script (e.g.,
echo hi
).
This example assumes you’re using GitHub Actions, which is one of the most popular CI/CD tools and supports YAML workflows.
.github/workflows/x-folder-change.yml
name: Run on x-folder change in development
on:
push:
branches:
- development
paths:
- 'x/**'
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run script
run: echo hi
Explanation
branches: development
: Only triggers when pushing to thedevelopment
branch.paths: 'x/**'
: Only triggers when files inside thex/
folder are changed.echo hi
: This is your sample script.
If you’re using another CI/CD platform (like GitLab CI, Azure Pipelines, or Bitbucket Pipelines), let me know — the syntax and approach will be a bit different.