Merge pull request #519 from robinklaassen/renovate/actions-checkout-4.x #1176
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: CI | |
on: [push] | |
env: | |
PHP_VERSION: "8.1" | |
PHP_EXTENSIONS: "xdebug, zip, xmlwriter, xmlreader, xml, tokenizer, pdo, phar, openssl, pcre, simplexml, gd, dom, curl" | |
NODE_VERSION: "19" | |
jobs: | |
codestyle: | |
name: Code style | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{env.PHP_VERSION}} | |
extensions: ${{env.PHP_EXTENSIONS}} | |
- name: Install composer dependencies | |
run: composer install --prefer-dist | |
- name: Easy coding Standard | |
run: vendor/bin/ecs check --config=ecs.php --no-progress-bar | |
frontend: | |
name: Front-end test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{env.NODE_VERSION}} | |
- name: Install yarn dependencies | |
run: yarn install | |
- name: Compile assets | |
run: | | |
yarn prod | |
tests: | |
name: PHP tests | |
runs-on: ubuntu-latest | |
env: | |
MYSQL_USER: ranonkeltje | |
MYSQL_PASSWORD: ranonkeltje | |
MYSQL_DATABASE: aas2 | |
MYSQL_ROOT_PASSWORD: ranonkeltje | |
services: | |
mariadb: | |
image: mariadb:10 | |
ports: | |
- 3306 | |
env: | |
MYSQL_USER: ranonkeltje | |
MYSQL_PASSWORD: ranonkeltje | |
MYSQL_DATABASE: aas2 | |
MYSQL_ROOT_PASSWORD: ranonkeltje | |
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{env.PHP_VERSION}} | |
extensions: ${{env.PHP_EXTENSIONS}} | |
coverage: xdebug | |
- name: Install composer dependencies | |
run: composer install --prefer-dist | |
- name: Setup project | |
env: | |
MYSQL_HOST: 127.0.0.1 | |
MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} | |
run: | | |
envsubst < .env.github > .env | |
php artisan key:generate | |
php artisan env | |
php artisan migrate --seed | |
- name: Run unit tests | |
run: vendor/bin/phpunit | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [tests, codestyle, frontend] | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/feature/github-actions' | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{env.NODE_VERSION}} | |
- name: Install yarn dependencies | |
run: yarn install | |
- name: Compile assets | |
run: | | |
yarn prod | |
- name: Move assets for transport | |
run: "mkdir deploy-unit && mv -t deploy-unit public/css public/js public/fonts" | |
- name: Upload assets | |
uses: SamKirkland/[email protected] | |
with: | |
server: ${{ secrets.FTP_HOSTNAME }} | |
username: ${{ secrets.FTP_USERNAME }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
local-dir: "./deploy-unit/" | |
server-dir: ${{ secrets.FTP_REMOTE_DIR }} | |
- name: Deploy application | |
id: req | |
uses: fjogeleit/http-request-action@master | |
with: | |
url: https://aas2.anderwijs.nl/updater/update?secret=${{ secrets.UPDATER_SECRET }} | |
method: GET | |
timeout: 60000 | |
preventFailureOnNoResponse: true | |
- name: Show response | |
run: echo ${{ steps.req.outputs.response }} |