docs #106
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
on: | |
push: | |
branches: [ '**' ] | |
pull_request: | |
branches: [ '**' ] | |
name: "CI" | |
jobs: | |
tests: | |
name: "Tests" | |
runs-on: "ubuntu-latest" | |
env: | |
php_extensions: ctype, dom, fileinfo, hash, intl, mbstring, session, simplexml, tokenizer, xml, pdo, mysqli, gd, zip | |
services: | |
mysql: | |
image: "mysql:5.7" | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_ROOT_PASSWORD: | |
MYSQL_DATABASE: test_db | |
ports: | |
- 3306/tcp | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- "7.4" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v2" | |
- name: "Install PHP with extensions" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "${{ matrix.php-version }}" | |
extensions: "${{ env.php_extensions }}" | |
coverage: "xdebug" | |
- name: "Start mysql service" | |
run: "sudo /etc/init.d/mysql start" | |
- name: "Cache dependencies installed with composer" | |
uses: "actions/cache@v1" | |
with: | |
path: "~/.composer/cache" | |
key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}" | |
restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" | |
- name: "Install dependencies with composer" | |
run: "composer install --no-ansi --no-interaction --no-progress" | |
- name: "Run tests with phpunit/phpunit" | |
env: | |
SS_DATABASE_PORT: ${{ job.services.mysql.ports['3306'] }} | |
BUGSNAG_API_KEY: abc123 | |
run: "vendor/bin/phpunit --coverage-clover=coverage.xml" | |
- name: "Upload coverage results to CodeCov" | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.xml # optional | |
flags: unittests # optional | |
- name: Post to a Slack channel | |
id: slack | |
uses: slackapi/slack-github-action@v1.22.0 | |
with: | |
# Slack channel id, channel name, or user id to post message. | |
# See also: https://api.slack.com/methods/chat.postMessage#channels | |
# You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs. | |
channel-id: 'C043V173Y59' | |
# For posting a simple plain text message | |
slack-message: "GitHub build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_KEY }} | |
deployment: | |
runs-on: ubuntu-latest | |
needs: [tests] | |
if: | | |
always() && (needs.tests.result == 'success') | |
steps: | |
- name: Deploy Stage | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: 'https://packagist.org/api/update-package?username=JanSneeuw&apiToken=${{ secrets.PACKAGIST_SECRET }}' | |
method: 'POST' | |
customHeaders: '{"Content-Type": "application/json"}' | |
data: '{"repository":{"url":"https://packagist.org/packages/violet88/bugsnag-silverstripe"}}' | |