पाठ 7 / 23
एक न्यूनतम वर्कफ़्लो
न्यूनतम GitHub Actions workflow लिखें जो main पर हर push पर आपके tests अपने-आप चलाए।
GitHub Actions क्या है
GitHub Actions GitHub का बिल्ट-इन CI/CD इंजन है। आप .github/workflows/ में YAML फ़ाइलों के रूप में वर्कफ़्लो परिभाषित करते हैं, और GitHub उन्हें पुश या पुल रिक्वेस्ट जैसी घटनाओं पर चलाता है।
हर पुश पर टेस्ट चलाएँ
यह वर्कफ़्लो main पर पुश होने पर शुरू होता है, कोड चेकआउट करता है, Node सेटअप करता है, डिपेंडेंसी इंस्टॉल करता है, और टेस्ट सूट चलाता है।
name: CI
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm test
Output:
Runs automatically on GitHub-hosted infrastructure
फ़ाइल कहाँ रहती है
.github/workflows/*.yml के अंतर्गत हर फ़ाइल एक अलग वर्कफ़्लो है। GitHub इन्हें स्वचालित रूप से उठाता है — कोई अलग सेटअप या डैशबोर्ड कॉन्फ़िगरेशन नहीं चाहिए।