Files
FOSSBilling/.github/workflows/ci.yml
T
30b6894600 Apply PHP Code Styling & Quality Changes (#3216)
* Apply PHP Code Styling & Quality Changes

* Remove unwnated file

* Apply PHP Code Styling & Quality Changes

* Remove unwnated file

* Update PHPUnit version to 12 in CI workflow

Bump the PHPUnit version from 10 to 12 in the GitHub Actions CI configuration to ensure tests run against the latest PHPUnit release.

* Refactor HTML sanitizer instantiation

* Refactor object instantiation

---------

Co-authored-by: FOSSBilling Bot <fossbilling-bot>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2026-01-28 20:15:28 +00:00

134 lines
4.5 KiB
YAML

name: CI
on:
push:
pull_request:
branches: main
jobs:
spellcheck:
name: 'Spellcheck'
permissions:
contents: read
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id) || github.event_name == 'push' }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: 'Perform Spellcheck'
uses: streetsidesoftware/cspell-action@d5d910b521ad408f1e7383c24609079f5a88bdca # v8
with:
incremental_files_only: true
php-build-test:
name: 'PHP Build and Test'
permissions:
contents: read
needs: [ spellcheck ]
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id) || github.event_name == 'push' }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.3, 8.4]
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: 'PHP Build'
uses: FOSSBilling/.workflows/.github/actions/php-build@11c3d3bb2ce6915aa0fc8af3165402a65400b084
with:
php-version: ${{ matrix.php }}
- name: 'Prepare Test Environment'
run: |
cp ./src/config-sample.php ./src/config.php
mkdir -p ./src/data/{cache,log}
echo APP_ENV=test >> $GITHUB_ENV
- name: 'PHP Tests (PHPStan and PHPUnit)'
uses: FOSSBilling/.workflows/.github/actions/php-test@11c3d3bb2ce6915aa0fc8af3165402a65400b084
with:
php-version: ${{ matrix.php }}
phpstan-enable: 'true'
phpstan-php-version: 8.4
phpstan-version: 'latest'
phpunit-enable: 'true'
phpunit-version: 12
preview-build:
name: 'Create Preview Release'
permissions:
contents: read
needs: [ php-build-test ]
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id) || github.event_name == 'push' }}
uses: ./.github/workflows/release-build.yml
with:
artifact-name: 'preview-build'
preview: true
upload-preview:
name: 'Upload Preview Release'
permissions:
contents: read
needs: [ preview-build ]
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: 'Download Preview Release Archive'
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: preview-build
path: '/tmp'
- name: 'Extract Preview Release Archive'
run: |
mkdir ./src
tar -xvf /tmp/build.tar -C ./src
- name: 'Create Downloadable Preview'
run: zip -r ../FOSSBilling-preview.zip .
working-directory: ./src/
- name: 'Move Downloadable Preview for Upload'
run: |
mkdir ./dist
mv ./FOSSBilling-preview.zip ./dist
- name: 'Upload Downloadable Preview to S3'
if: ${{ github.ref == 'refs/heads/main' }}
uses: jakejarvis/s3-sync-action@master
with:
args: '--acl public-read --follow-symlinks'
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
AWS_REGION: 'auto'
SOURCE_DIR: './dist'
- name: 'Upload Downloadable Preview to GitHub'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
if-no-files-found: 'error'
name: 'FOSSBilling Preview'
path: './src/*'
retention-days: 14
deploy-preview-docker:
name: 'Build and Push Preview to Docker Hub'
permissions:
contents: read
actions: write
needs: [ preview-build ]
if: ${{ github.ref == 'refs/heads/main' }}
uses: FOSSBilling/.workflows/.github/workflows/docker-build-push.yml@11c3d3bb2ce6915aa0fc8af3165402a65400b084
secrets:
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
with:
download-artifact: 'preview-build'
platforms: '["linux/amd64", "linux/arm64"]'
repository-name: 'fossbilling/fossbilling'
tag-latest: 'false'
tag-raw: 'preview'