name: Conditional Build | |
on: | |
push: | |
branches: | |
- main | |
# Run the build only when changes are detected in specific directories | |
paths: | |
- 'src/**' | |
- 'scripts/**' | |
# Exclude the build if changes are only detected in specific directories | |
paths-ignore: | |
- 'docs/**' | |
- 'tests/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: npm install | |
- name: Run build | |
run: npm run build |
Explanation:
on.push.paths
: Specifies the directories/files that should trigger the workflow. In this case, changes in thesrc/
orscripts/
directories will trigger the build.on.push.paths-ignore
: Specifies the directories/files that should not trigger the workflow. If changes are only in thedocs/
ortests/
directories, the build will be skipped.
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND