Files
Jeremy 411a4b3e50 ci: avoid duplicate runs on PR branches
Scope push triggers to main and v* tags so a branch with an open PR no longer
runs CI twice (push + pull_request). Tag pushes still drive the docker build.
2026-06-18 23:27:27 +10:00

86 lines
2.1 KiB
YAML
Executable File

on:
push:
branches: [main]
tags: ['v*']
pull_request:
name: CI
jobs:
tests:
runs-on: ubuntu-latest
container:
image: jez500/pricebuddy-tests-8.4:latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: tests_db
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
-
uses: actions/checkout@v1
with:
fetch-depth: 1
-
name: Install composer dependencies
run: |
composer install --no-scripts
-
name: Install front-end dependencies
run: |
npm install
npm run build
-
name: Prepare Laravel Application
run: |
cp .env.ci .env
php artisan key:generate
-
name: Check coding standards
run: vendor/bin/pint --test -vv
-
name: Static code analysis
run: vendor/bin/phpstan analyse --memory-limit=1G
-
name: Run Testsuite
run: |
sed -i -e 's/tests_db/mysql/g' phpunit.xml
php -d memory_limit=512M artisan test -p
docker_build_push:
if: startsWith(github.ref, 'refs/tags/v')
needs: tests
runs-on: ubuntu-latest
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Update version file
run: echo "${{ github.ref_name }}" > VERSION
-
name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
file: ./docker/php.dockerfile
push: true
tags: |
jez500/pricebuddy:${{ github.ref_name }}
jez500/pricebuddy:latest
build-args: |
APP_VERSION=${{ github.ref_name }}