Skip to content

Commit

Permalink
(feat): shared badge workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonvanWijhe committed Dec 10, 2024
1 parent 974c6c2 commit cb535e6
Showing 1 changed file with 3 additions and 64 deletions.
67 changes: 3 additions & 64 deletions .github/workflows/badges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,11 @@ on:
types: [published]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
pull-requests: write

jobs:
badges:
name: Create badges
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: '8.1'
extensions: simplexml, dom, xml, xdebug, intl
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.YARD_BOT_PAT }}

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Recreate autoload file
run: composer dump-autoload

- name: Run Unit Tests
run: XDEBUG_MODE_COVERAGE=coverage vendor/bin/pest --coverage-clover=clover.xml

- name: Make lines of code badge
uses: DeathSy/[email protected]
id: badge
with:
debug: true
directory: ./src
patterns: '**/*.php'
badge: ./output/lines-of-code.svg

- name: Make code coverage badge
uses: timkrase/[email protected]
with:
coverage_badge_path: output/coverage.svg
push_badge: false

- name: Git push to badges branch
uses: peaceiris/actions-gh-pages@v4
with:
publish_dir: ./output
publish_branch: badges
github_token: ${{ secrets.GITHUB_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
composer-diff:
uses: yardinternet/workflows/.github/workflows/badges.yml@main
secrets: inherit

0 comments on commit cb535e6

Please sign in to comment.