Skip to content

Make coverage.yml delete the old coverage branch on every report generation #2

Make coverage.yml delete the old coverage branch on every report generation

Make coverage.yml delete the old coverage branch on every report generation #2

Workflow file for this run

name: PHP Composer
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: write
jobs:
generate-coverage-report:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci]')"
defaults:
run:
working-directory: ./source
steps:
- name: Setup PHP 8.3
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Checkout code
uses: actions/checkout@v3
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite with coverage
run: composer coverage
- name: Generate coverage badge
uses: timkrase/phpunit-coverage-badge@v1.2.1
with:
report: source/build/logs/clover.xml
report_type: clover
coverage_badge_path: source/build/logs/coverage.svg
push_badge: false
- name: Delete the old coverage branch
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{github.token}}
branches: coverage-data
soft_fail: true
- name: Push coverage data to coverage branch
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: ./source/build/logs
publish_branch: coverage-data
github_token: ${{ secrets.GITHUB_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
full_commit_message: Update coverage data