Skip to content

Build application

Build application #89

Workflow file for this run

name: Build application
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag version'
required: true
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Extract the tag version
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
GITHUB_REF=${{ github.event.inputs.tag }}
fi
echo "tag=${GITHUB_REF##*v}" >> "$GITHUB_OUTPUT"
- name: Checkout the code
uses: actions/checkout@v3
with:
submodules: true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv, json, dom, curl, libxml, fileinfo, tokenizer, xml
ini-values: error_reporting=E_ALL
coverage: none
- name: Git setup
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --global core.autocrlf false
git config --global core.eol lf
- name: Install the dependencies
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
- name: Execute unit/feature tests
run: php ./codestyle test --colors=always
- name: Create the PHAR file
run: php ./codestyle app:build codestyle --build-version=${{ steps.tag.outputs.tag }} --ansi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: codestyle_build
path: builds/codestyle
retention-days: 1
checks:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest", "windows-latest" ]
name: Check with ${{ matrix.os }}
steps:
- uses: actions/download-artifact@v3
with:
name: codestyle_build
path: builds/codestyle
- name: Show version
run: php ./builds/codestyle --version
- name: Run codestyler
run: php ./builds/codestyle test --colors=always
push:
runs-on: ubuntu-latest
needs: checks
steps:
- uses: actions/download-artifact@v3
with:
name: codestyle_build
path: builds/codestyle
- name: Commit the PHAR file
id: build
run: |
IS_DIRTY=1
{ git add ./builds/codestyle && git commit -a -m "🏗️ Build application"; } || IS_DIRTY=0
echo "is_dirty=${IS_DIRTY}" >> "$GITHUB_OUTPUT"
- name: Push changes
uses: ad-m/github-push-action@master
if: steps.build.outputs.is_dirty == 1
with:
github_token: ${{ secrets.COMPOSER_TOKEN }}