Merge pull request #40 from tbreuss/develop #62
This file contains hidden or 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 | |
| on: [push, pull_request] | |
| jobs: | |
| test: | |
| name: Analyse and Test Code | |
| strategy: | |
| matrix: | |
| operating-system: [ubuntu-latest] | |
| php-versions: ['8.2', '8.3', '8.4'] | |
| runs-on: ${{ matrix.operating-system }} | |
| steps: | |
| - name: Checkout git repository | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-versions }} | |
| extensions: mbstring | |
| coverage: xdebug | |
| - name: Set composer cache directory | |
| id: composer-cache | |
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
| - name: Cache composer dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install composer dependencies | |
| run: composer install --no-progress --prefer-dist --optimize-autoloader | |
| - name: Test coding style | |
| run: bin/coding-style.sh | |
| - name: Run static code analysis | |
| run: bin/code-analysis.sh | |
| - name: Run functional tests | |
| run: bin/functional.sh localhost:9876 | |
| - name: Run website tests | |
| run: bin/website.sh localhost:9875 | |
| publish: | |
| name: Publish Website | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout git repository | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP and Composer | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.4 | |
| tools: composer:v2 | |
| - name: Install PHP dependencies | |
| run: composer install --working-dir website --no-dev --prefer-dist --no-progress --no-suggest --optimize-autoloader | |
| - name: Rename index-prod.php to index.php | |
| run: rm website/web/index.php && mv website/web/index-prod.php website/web/index.php | |
| - name: Deploy code to server with scp | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| password: ${{ secrets.SSH_PASSWORD }} | |
| port: 22 | |
| source: "website" | |
| target: ${{ secrets.SSH_TARGET }} | |
| rm: true | |
| strip_components: 1 |