@@ -3,19 +3,81 @@ name: deployment
33
44on :
55 push :
6- branches :
7- - develop
8- - phoenix
6+ pull_request :
97 workflow_dispatch :
8+ inputs :
9+ php_version :
10+ description : " Specify the PHP version to use (e.g., 8.3)"
11+ required : false
12+ default : ' 8.3'
1013
1114env :
12- PHP_VERSION : ' 8.3'
15+ PHP_VERSION : ${{ inputs.php_version || '8.3' }}
1316
1417permissions :
1518 contents : read
1619
1720jobs :
21+ linter :
22+ runs-on : ubuntu-latest
23+ steps :
24+ - name : Checkout
25+ uses : actions/checkout@v4
26+
27+ - name : Update apt cache
28+ run : sudo apt-get update
29+
30+ - name : Install PHP ${{ env.PHP_VERSION }}
31+ run : sudo apt-get install php${{ env.PHP_VERSION }}-cli php${{ env.PHP_VERSION }}-mbstring php${{ env.PHP_VERSION }}-xml
32+
33+ - name : Validate composer.json and composer.lock
34+ run : composer validate --strict
35+
36+ - name : Cache Composer packages
37+ id : composer-cache
38+ uses : actions/cache@v4
39+ with :
40+ path : lib
41+ key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
42+ restore-keys : |
43+ ${{ runner.os }}-php-
44+
45+ - name : Install composer/vendor dependencies
46+ run : composer install --prefer-dist --no-progress --ignore-platform-reqs
47+
48+ - name : Validate PHP syntax
49+ run : bash -c 'set -e;for file in $(find ./src ./tests -type f -regex ".*\.\(php\|phtml\)" -print); do php -e -l -f "$file"; done'
50+
51+ tests :
52+ runs-on : ubuntu-latest
53+ steps :
54+ - name : Checkout
55+ uses : actions/checkout@v4
56+
57+ - name : Update apt cache
58+ run : sudo apt-get update
59+
60+ - name : Install PHP ${{ env.PHP_VERSION }}
61+ run : sudo apt-get install php${{ env.PHP_VERSION }}-cli php${{ env.PHP_VERSION }}-mbstring php${{ env.PHP_VERSION }}-xml
62+
63+ - name : Cache Composer packages
64+ id : composer-cache
65+ uses : actions/cache@v4
66+ with :
67+ path : lib
68+ key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
69+ restore-keys : |
70+ ${{ runner.os }}-php-
71+
72+ - name : Install composer/vendor dependencies
73+ run : composer install --prefer-dist --no-progress --ignore-platform-reqs
74+
75+ - name : Run PHPUnit tests
76+ run : lib/bin/phpunit --testdox
77+
1878 deploy :
79+ needs : [linter, tests]
80+ if : github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/phoenix')
1981 runs-on : ubuntu-latest
2082 environment : production
2183 steps :
3193 - name : Install PHP ${{ env.PHP_VERSION }}
3294 run : sudo apt-get install php${{ env.PHP_VERSION }}-cli php${{ env.PHP_VERSION }}-mbstring php${{ env.PHP_VERSION }}-xml
3395
34- - name : Validate composer.json and composer.lock
35- run : composer validate --strict
36-
3796 - name : Cache Composer packages
3897 id : composer-cache
3998 uses : actions/cache@v4
46105 - name : Install composer/vendor dependencies
47106 run : composer install --prefer-dist --no-progress --ignore-platform-reqs
48107
49- - name : Validate PHP syntax
50- run : bash -c 'set -e;for file in $(find ./src -type f -regex ".*\.\(php\|phtml\)" -print); do php -e -l -f "$file"; done'
51-
52108 - name : Sanitize Branch Name
53109 run : |
54110 CLEAN_BRANCH_NAME="${GITHUB_REF_NAME//\//_}"
0 commit comments