chore(deps): bump debian from 11.4-slim to 12.8-slim in /.docker #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub Actions | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
permissions: write-all | |
concurrency: | |
group: actions-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
IMAGE_NAME: ghcr.io/simonprinz/accountable | |
jobs: | |
# | |
# Code Style | |
codestyle_php_phpstan: | |
runs-on: ubuntu-latest | |
name: Check PHP Code Style (PHPStan) | |
if: github.event_name == 'pull_request' && github.ref_type == 'branch' | |
env: | |
APP_ENV: ci | |
VERSION: ci | |
steps: | |
- name: π Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: βοΈ Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
- name: ποΈ Check cache for composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: vendor/ | |
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | |
${{ runner.os }}-composer- | |
- name: π¦ Install composer dependencies | |
run: composer install | |
- name: π§ Inspecting your code | |
run: composer run phpstan | |
# | |
# Tests | |
test_php: | |
runs-on: ubuntu-latest | |
name: Test PHP | |
if: "!failure() && !cancelled() && !(github.event_name == 'release' && github.ref_type == 'tag')" | |
needs: | |
- codestyle_php_phpstan | |
services: | |
database: | |
image: mysql:8.0.32 | |
options: --name database --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10 | |
env: | |
MYSQL_ROOT_PASSWORD: toor | |
MYSQL_HOST: 0.0.0.0 | |
ports: | |
- 3306:3306 | |
env: | |
APP_ENV: ci | |
VERSION: ci | |
steps: | |
- name: π Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: πΎ Save database ip to env | |
run: | | |
echo "DATABASE_URL=mysql://root:toor@$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' database):3306/accountable?serverVersion=8.0.13&charset=utf8mb4" >> $GITHUB_ENV | |
- name: βοΈ Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
coverage: xdebug | |
- name: βοΈ Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: ποΈ Check cache for composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: vendor/ | |
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | |
${{ runner.os }}-composer- | |
- name: π¦ Install composer dependencies | |
run: composer install | |
- name: ποΈ Check cache for npm dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} | |
${{ runner.os }}-npm- | |
- name: π¦ Install npm dependencies | |
run: npm install | |
- name: π οΈ Build encore files | |
run: npm run build | |
- name: π Create database | |
run: php bin/console --env=test -vvv doctrine:database:create | |
- name: πͺ« Prepare database | |
run: php bin/console --env=test -vvv doctrine:migrations:migrate --no-interaction | |
- name: π Generating demo data | |
run: php bin/console --env=test -vvv doctrine:fixtures:load --no-interaction | |
- name: π§ͺ Run tests | |
run: php bin/phpunit -v --debug --log-junit var/php_junit.xml --coverage-clover var/php_clover.xml | |
- name: π Publish test report | |
uses: mikepenz/action-junit-report@v5 | |
if: success() || failure() | |
with: | |
report_paths: var/php_junit.xml | |
check_name: "PHP Test Report" | |
fail_on_failure: false | |
require_tests: true | |
detailed_summary: true | |
- name: π¬ Reporting coverage to PR | |
uses: lucassabreu/comment-coverage-clover@main | |
if: (success() || failure()) && github.ref_name != 'main' | |
with: | |
github-token: ${{ secrets.GHPAT || github.token }} | |
file: var/php_clover.xml | |
# | |
# Docker | |
docker_check-changes: | |
runs-on: ubuntu-latest | |
name: Check for Docker changes | |
if: "!failure() && !cancelled() && !(github.event_name == 'release' && github.ref_type == 'tag')" | |
needs: | |
- test_php | |
outputs: | |
docker: ${{ steps.filter.outputs.docker }} | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: π Checking for changes | |
uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
docker: | |
- '.docker/**' | |
docker_test-dev: | |
name: Test Dev Docker Image | |
needs: | |
- docker_check-changes | |
if: "!failure() && !cancelled() && github.event_name == 'pull_request' && github.ref_type == 'branch' && github.ref_name != 'main' && needs.docker_check-changes.outputs.docker == 'true'" | |
env: | |
VERSION: dev | |
runs-on: ubuntu-latest | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: π Login to GitHub Container Registry | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $ --password-stdin | |
- name: π§ Build the Docker image | |
run: docker build . -f .docker/Dockerfile --target dev -t ${IMAGE_NAME}:${VERSION} | |
docker_test-prod: | |
name: Test Prod Docker Image | |
needs: | |
- docker_check-changes | |
if: "!failure() && !cancelled() && github.event_name == 'pull_request' && github.ref_type == 'branch' && github.ref_name != 'main' && (needs.docker_check-changes.outputs.docker == 'true')" | |
env: | |
VERSION: prod | |
runs-on: ubuntu-latest | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: π Login to GitHub Container Registry | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $ --password-stdin | |
- name: π§ Build the Docker image | |
run: docker build . -f .docker/Dockerfile --target prod --build-arg="VERSION=${VERSION}" -t ${IMAGE_NAME}:${VERSION} | |
docker_build-latest: | |
name: Build Latest Docker Image | |
needs: | |
- test_php | |
if: "!failure() && !cancelled() && github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'main'" | |
env: | |
VERSION: "latest" | |
runs-on: ubuntu-latest | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: π Login to GitHub Container Registry | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $ --password-stdin | |
- name: π§ Build the Docker image | |
run: docker build . -f .docker/Dockerfile --target prod --build-arg="VERSION=${VERSION}" -t ${IMAGE_NAME}:${VERSION} | |
- name: β€΄οΈ Push the Docker image to GitHub Container Registry | |
run: docker push ${IMAGE_NAME}:${VERSION} | |
docker_build-release: | |
name: Build Release Docker Image | |
needs: | |
- test_php | |
if: "!failure() && !cancelled() && github.event_name == 'release' && github.ref_type == 'tag'" | |
env: | |
VERSION: ${{ github.ref_name }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
# use custom token to trigger workflows | |
token: ${{ secrets.GHPAT || github.token }} | |
- name: π Login to GitHub Container Registry | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $ --password-stdin | |
- name: π§ Build the Docker image | |
run: docker build . -f .docker/Dockerfile --target prod --build-arg="VERSION=${VERSION}" -t ${IMAGE_NAME}:${VERSION} | |
- name: β€΄οΈ Push the Docker image to GitHub Container Registry | |
run: docker push ${IMAGE_NAME}:${VERSION} |