|
| 1 | +name: Lighthouse Performance & SEO Audit |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [gh-pages] |
| 6 | + schedule: |
| 7 | + # Audit automatique chaque jour à 2h du matin (UTC) |
| 8 | + - cron: '0 2 * * *' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + issues: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + lighthouse-audit: |
| 18 | + name: Audit Lighthouse de davidkrk.com |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + ref: gh-pages |
| 25 | + |
| 26 | + - name: Attendre le déploiement GitHub Pages |
| 27 | + run: sleep 60 |
| 28 | + |
| 29 | + - name: Audit Lighthouse |
| 30 | + uses: treosh/lighthouse-ci-action@v11 |
| 31 | + with: |
| 32 | + urls: | |
| 33 | + https://www.davidkrk.com |
| 34 | + https://www.davidkrk.com/music.html |
| 35 | + https://www.davidkrk.com/bio.html |
| 36 | + https://www.davidkrk.com/contact.html |
| 37 | + uploadArtifacts: true |
| 38 | + temporaryPublicStorage: true |
| 39 | + |
| 40 | + - name: Créer badge de performance |
| 41 | + run: | |
| 42 | + mkdir -p .github/badges |
| 43 | + echo '{"schemaVersion": 1, "label": "Lighthouse", "message": "Performance", "color": "brightgreen"}' > .github/badges/lighthouse.json |
| 44 | +
|
| 45 | + - name: Commit du badge |
| 46 | + run: | |
| 47 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 48 | + git config --local user.name "github-actions[bot]" |
| 49 | + git add .github/badges/lighthouse.json || true |
| 50 | + git commit -m "chore: mise à jour du badge Lighthouse" || true |
| 51 | + git push || true |
| 52 | +
|
| 53 | + - name: Créer issue si score faible |
| 54 | + if: failure() |
| 55 | + uses: actions/github-script@v7 |
| 56 | + with: |
| 57 | + script: | |
| 58 | + github.rest.issues.create({ |
| 59 | + owner: context.repo.owner, |
| 60 | + repo: context.repo.repo, |
| 61 | + title: '⚠️ Score Lighthouse faible détecté', |
| 62 | + body: `Le score Lighthouse est tombé en dessous du seuil acceptable.\n\nVérifiez les résultats de l'audit dans les artifacts de ce workflow.`, |
| 63 | + labels: ['performance', 'automated'] |
| 64 | + }) |
0 commit comments