diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index f013d34..9d92985 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -1,4 +1,4 @@ -name: Test +name: Test and Deploy on: push: branches: [ '*' ] @@ -21,42 +21,55 @@ jobs: dependencies: - "lowest" - "highest" - steps: - - name: Checkout php-http-client - uses: actions/checkout@v2 + - name: Checkout php-http-client + uses: actions/checkout@v2 + + - name: Setup PHP Action + uses: shivammathur/setup-php@2.15.0 + with: + php-version: ${{ matrix.php }} + id: php + + - name: Composer webhook config + run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} - - name: Setup PHP Action - uses: shivammathur/setup-php@2.15.0 - with: - php-version: ${{ matrix.php }} - id: php + - name: Install dependencies + run: composer install - - name: Composer webhook config - run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + - name: Update Dependencies + if: ${{ matrix.dependencies == 'lowest' }} + run: composer update --prefer-lowest --prefer-stable -n - - name: Install dependencies - run: composer install + - name: Run Tests + run: make test - - name: Update Dependencies - if: ${{ matrix.dependencies == 'lowest' }} - run: composer update --prefer-lowest --prefer-stable -n + deploy: + name: Deploy + if: success() && github.ref_type == 'tag' + needs: [ test ] + runs-on: ubuntu-latest + steps: + - name: Checkout php-http-client + uses: actions/checkout@v2 - - name: Run Tests - run: make test + - name: Create GitHub Release + uses: sendgrid/dx-automator/actions/release@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} notify-on-failure: name: Slack notify on failure - if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }} - needs: [test] + if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') + needs: [ test, deploy ] runs-on: ubuntu-latest steps: - uses: rtCamp/action-slack-notify@v2 env: SLACK_COLOR: failure SLACK_ICON_EMOJI: ':github:' - SLACK_MESSAGE: ${{ format('Build {2} in {1} failed{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }} - SLACK_TITLE: Build Failure + SLACK_MESSAGE: ${{ format('Tests *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} + SLACK_TITLE: Action Failure - ${{ github.repository }} SLACK_USERNAME: GitHub Actions SLACK_MSG_AUTHOR: twilio-dx SLACK_FOOTER: Posted automatically using GitHub Actions