chore: simplification du remplissage des issues et des pull requests + nouveaux workflows + fixs extentions de fichiers incorrects #1209
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Checks (TypeScript + ESLint) | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
lint-main: | |
name: 🛠️ TypeScript and ESLint on Main | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/remotes/origin/main' | |
steps: | |
- name: 📥 Checkout code | |
uses: actions/checkout@v3 | |
- name: ⚙️ Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- name: 💾 Install dependencies | |
run: npm ci | |
- name: 🔍 Run TypeScript and ESLint checks | |
run: | | |
tsc > tsc.log 2>&1 || true | |
eslint . > eslint.log 2>&1 || true | |
cat tsc.log eslint.log > lint.log | |
continue-on-error: true | |
- name: 📄 Output Logs | |
run: cat lint.log | |
- name: 🛠️ Commit and Push Fixes (Main) | |
if: success() || failure() | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
if git diff --quiet; then | |
echo "No changes to commit." | |
else | |
git add . | |
git commit -m "🔧 Auto-fix ESLint issues" | |
git push | |
fi | |
- name: 🧹 Clean up | |
if: always() | |
run: rm -f lint.log tsc.log eslint.log | |
lint-development: | |
name: 🛠️ TypeScript and ESLint on Pull Request | |
runs-on: ubuntu-latest | |
if: github.ref != 'refs/remotes/origin/main' | |
steps: | |
- name: 📥 Checkout code | |
uses: actions/checkout@v3 | |
- name: ⚙️ Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- name: 💾 Install dependencies | |
run: npm ci | |
- name: 🔍 Run TypeScript and ESLint checks | |
run: | | |
npx tsc > tsc.log 2>&1 || true | |
npx eslint . > eslint.log 2>&1 || true | |
cat tsc.log eslint.log > lint.log | |
continue-on-error: true | |
- name: 📋 Check if lint logs are empty | |
id: check_logs | |
run: | | |
if [ -s lint.log ]; then | |
echo "is_empty=false" >> $GITHUB_ENV | |
else | |
echo "is_empty=true" >> $GITHUB_ENV | |
fi | |
- name: 📄 Output Logs | |
run: cat lint.log | |
- name: 👁️🗨️ Comment on Pull Request | |
if: env.is_empty == 'false' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const lintLogContent = fs.readFileSync('lint.log', 'utf8'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `⚠️ Erreur(s) détectée(s) par TypeScript/ESLint !\n\`\`\`\n${lintLogContent}\n\`\`\`` | |
}); | |
- name: 🧹 Clean up | |
if: always() | |
run: rm -f lint.log tsc.log eslint.log |