Merge pull request #210 from SlovakNationalGallery/fix/KOMARCH-298 #1299
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/CD | |
# Trigger test on every push, deploy only after push on master branch after test | |
on: push | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-22.04 | |
services: | |
mysql: | |
image: mysql:5.7.32 | |
env: | |
MYSQL_DATABASE: komarch_testing | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
ports: | |
- 3306 | |
elasticsearch: | |
image: slovaknationalgallery/elasticsearch-webumenia:7.3.1 | |
env: | |
discovery.type: single-node | |
ports: | |
- 9200 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Restore Composer cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Restore npm cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
extensions: mbstring, bcmath, fileinfo, pdo_mysql | |
- name: Add Composer auth credentials (for Backpack Pro) | |
run: echo '${{ secrets.COMPOSER_AUTH_JSON }}' > $GITHUB_WORKSPACE/auth.json | |
- run: composer install --no-progress --no-interaction | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- run: npm install && npm run production | |
- run: ./vendor/bin/phpunit | |
env: | |
APP_KEY: base64:HXaE/pTpPoSNdHFMl5SpgX2XKtdph3EjrdmvWFDKisE= | |
DATABASE_URL: mysql://root:@127.0.0.1:${{ job.services.mysql.ports[3306] }}/komarch_testing | |
ELASTIC_HOST: 127.0.0.1:${{ job.services.elasticsearch.ports[9200] }} | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-22.04 | |
needs: [test] | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
- name: Deploy | |
uses: deployphp/action@v1 | |
with: | |
private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} | |
known-hosts: ${{ secrets.DEPLOY_SSH_KNOWN_HOSTS }} | |
deployer-version: 7.3.0 | |
dep: deploy |