-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
76 lines (69 loc) · 2.36 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
name: 'PHPCS'
description: 'Execute php-cs-fixer'
inputs:
linters:
description: 'List of all enabled linters'
required: true
ssh-key:
description: 'ssh key'
required: true
github_token:
description: 'github token'
required: true
php-version:
description: 'php version'
required: false
default: '8.2'
php-extensions:
description: 'php extensions'
required: false
default: ''
composer-command:
description: 'composer command'
required: false
default: 'none'
php-cs-fixer-version:
description: 'php-cd-fixer version'
required: false
default: 'latest'
php-cs-fixer-command:
description: 'php-cs-fixer command(s)'
required: false
default: './php-cs-fixer fix --dry-run --diff --verbose'
runs:
using: "composite"
steps:
- id: check
shell: bash
run: if echo "${{ inputs.linters }}" | grep PHPCS &> /dev/null; then echo "continue=true" >> "${GITHUB_OUTPUT}"; else echo "continue=false" >> "${GITHUB_OUTPUT}"; fi
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v4
if: ${{ steps.check.outputs.continue == 'true' }}
with:
ssh-key: ${{ inputs.ssh-key }}
persist-credentials: true
lfs: true
submodules: recursive
# https://github.com/marketplace/actions/setup-php-action
- uses: shivammathur/setup-php@v2
if: ${{ steps.check.outputs.continue == 'true' }}
with:
php-version: ${{ inputs.php-version }}
extensions: ${{ inputs.php-extensions }}
tools: composer
- shell: bash
if: ${{ steps.check.outputs.continue == 'true' && inputs.composer-command == 'none'}}
run: |
if [ "${{ inputs.php-cs-fixer-version }}" == "latest" ] ;then
curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o php-cs-fixer && chmod a+x php-cs-fixer
else
curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/${{ inputs.php-cs-fixer-version }}/php-cs-fixer.phar -o php-cs-fixer && chmod a+x php-cs-fixer
fi
- shell: bash
if: ${{ steps.check.outputs.continue == 'true' && inputs.composer-command != 'none'}}
run: ${{ inputs.composer-command }}
# https://cs.symfony.com/doc/usage.html
- shell: bash
if: ${{ steps.check.outputs.continue == 'true' }}
run: ${{ inputs.php-cs-fixer-command }}