| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,113 +0,0 @@ |
| 1 |
-name: Test and Deploy |
|
| 2 |
-on: |
|
| 3 |
- push: |
|
| 4 |
- branches: [ '*' ] |
|
| 5 |
- tags: [ '*' ] |
|
| 6 |
- pull_request: |
|
| 7 |
- branches: [ main ] |
|
| 8 |
- schedule: |
|
| 9 |
- # Run automatically at 8AM PST Monday-Friday |
|
| 10 |
- - cron: '0 15 * * 1-5' |
|
| 11 |
- workflow_dispatch: |
|
| 12 |
- |
|
| 13 |
-jobs: |
|
| 14 |
- test: |
|
| 15 |
- name: Test |
|
| 16 |
- runs-on: ubuntu-latest |
|
| 17 |
- timeout-minutes: 20 |
|
| 18 |
- strategy: |
|
| 19 |
- matrix: |
|
| 20 |
- php: [ 7.2, 7.3, 7.4, 8.0, 8.1 ] |
|
| 21 |
- dependencies: |
|
| 22 |
- - "lowest" |
|
| 23 |
- - "highest" |
|
| 24 |
- steps: |
|
| 25 |
- - name: Checkout twilio-php |
|
| 26 |
- uses: actions/checkout@v2 |
|
| 27 |
- with: |
|
| 28 |
- fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
|
| 29 |
- |
|
| 30 |
- - name: Setup PHP Action |
|
| 31 |
- uses: shivammathur/setup-php@2.15.0 |
|
| 32 |
- with: |
|
| 33 |
- php-version: ${{ matrix.php }}
|
|
| 34 |
- coverage: xdebug |
|
| 35 |
- id: php |
|
| 36 |
- |
|
| 37 |
- - name: Composer webhook config |
|
| 38 |
- run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
|
|
| 39 |
- |
|
| 40 |
- - name: Update Dependencies |
|
| 41 |
- if: matrix.dependencies == 'lowest' |
|
| 42 |
- run: composer update --prefer-lowest --prefer-stable -n |
|
| 43 |
- |
|
| 44 |
- - name: Run Tests |
|
| 45 |
- run: make install test |
|
| 46 |
- |
|
| 47 |
- - name: Fix code coverage paths |
|
| 48 |
- run: | |
|
| 49 |
- if [ -f "coverage.xml" ]; then |
|
| 50 |
- sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml |
|
| 51 |
- fi |
|
| 52 |
- |
|
| 53 |
- - name: Install SonarCloud scanner and run analysis |
|
| 54 |
- uses: SonarSource/sonarcloud-github-action@master |
|
| 55 |
- if: (github.event_name == 'pull_request' || github.ref_type == 'branch') && !github.event.pull_request.head.repo.fork && matrix.php == '8.1' && matrix.dependencies == 'highest' |
|
| 56 |
- env: |
|
| 57 |
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
|
| 58 |
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
| 59 |
- |
|
| 60 |
- deploy: |
|
| 61 |
- name: Deploy |
|
| 62 |
- if: success() && github.ref_type == 'tag' |
|
| 63 |
- needs: [ test ] |
|
| 64 |
- runs-on: ubuntu-latest |
|
| 65 |
- steps: |
|
| 66 |
- - name: Checkout twilio-php |
|
| 67 |
- uses: actions/checkout@v2 |
|
| 68 |
- with: |
|
| 69 |
- fetch-depth: 0 |
|
| 70 |
- |
|
| 71 |
- - name: Install dependencies |
|
| 72 |
- run: composer install |
|
| 73 |
- |
|
| 74 |
- - name: Login to Docker Hub |
|
| 75 |
- uses: docker/login-action@v1 |
|
| 76 |
- with: |
|
| 77 |
- username: ${{ secrets.DOCKER_USERNAME }}
|
|
| 78 |
- password: ${{ secrets.DOCKER_AUTH_TOKEN }}
|
|
| 79 |
- |
|
| 80 |
- # The expression strips off the shortest match from the front of the string to yield just the tag name as the output |
|
| 81 |
- - name: Get tagged version |
|
| 82 |
- run: echo "GITHUB_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
| 83 |
- |
|
| 84 |
- - name: Create GitHub Release |
|
| 85 |
- uses: sendgrid/dx-automator/actions/release@main |
|
| 86 |
- env: |
|
| 87 |
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
| 88 |
- |
|
| 89 |
- - name: Build & Push docker image |
|
| 90 |
- run: make docker-build docker-push |
|
| 91 |
- |
|
| 92 |
- - name: Submit metric to Datadog |
|
| 93 |
- uses: sendgrid/dx-automator/actions/datadog-release-metric@main |
|
| 94 |
- env: |
|
| 95 |
- DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
|
|
| 96 |
- |
|
| 97 |
- notify-on-failure: |
|
| 98 |
- name: Slack notify on failure |
|
| 99 |
- if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
|
| 100 |
- needs: [ test, deploy ] |
|
| 101 |
- runs-on: ubuntu-latest |
|
| 102 |
- steps: |
|
| 103 |
- - uses: rtCamp/action-slack-notify@v2 |
|
| 104 |
- env: |
|
| 105 |
- SLACK_COLOR: failure |
|
| 106 |
- SLACK_ICON_EMOJI: ':github:' |
|
| 107 |
- SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
|
|
| 108 |
- SLACK_TITLE: Action Failure - ${{ github.repository }}
|
|
| 109 |
- SLACK_USERNAME: GitHub Actions |
|
| 110 |
- SLACK_MSG_AUTHOR: twilio-dx |
|
| 111 |
- SLACK_FOOTER: Posted automatically using GitHub Actions |
|
| 112 |
- SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
|
| 113 |
- MSG_MINIMAL: true |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,113 @@ |
| 1 |
+name: Test and Deploy |
|
| 2 |
+on: |
|
| 3 |
+ push: |
|
| 4 |
+ branches: [ '*' ] |
|
| 5 |
+ tags: [ '*' ] |
|
| 6 |
+ pull_request: |
|
| 7 |
+ branches: [ main ] |
|
| 8 |
+ schedule: |
|
| 9 |
+ # Run automatically at 8AM PST Monday-Friday |
|
| 10 |
+ - cron: '0 15 * * 1-5' |
|
| 11 |
+ workflow_dispatch: |
|
| 12 |
+ |
|
| 13 |
+jobs: |
|
| 14 |
+ test: |
|
| 15 |
+ name: Test |
|
| 16 |
+ runs-on: ubuntu-latest |
|
| 17 |
+ timeout-minutes: 20 |
|
| 18 |
+ strategy: |
|
| 19 |
+ matrix: |
|
| 20 |
+ php: [ 7.2, 7.3, 7.4, 8.0, 8.1 ] |
|
| 21 |
+ dependencies: |
|
| 22 |
+ - "lowest" |
|
| 23 |
+ - "highest" |
|
| 24 |
+ steps: |
|
| 25 |
+ - name: Checkout twilio-php |
|
| 26 |
+ uses: actions/checkout@v2 |
|
| 27 |
+ with: |
|
| 28 |
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
|
| 29 |
+ |
|
| 30 |
+ - name: Setup PHP Action |
|
| 31 |
+ uses: shivammathur/setup-php@2.15.0 |
|
| 32 |
+ with: |
|
| 33 |
+ php-version: ${{ matrix.php }}
|
|
| 34 |
+ coverage: xdebug |
|
| 35 |
+ id: php |
|
| 36 |
+ |
|
| 37 |
+ - name: Composer webhook config |
|
| 38 |
+ run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
|
|
| 39 |
+ |
|
| 40 |
+ - name: Update Dependencies |
|
| 41 |
+ if: matrix.dependencies == 'lowest' |
|
| 42 |
+ run: composer update --prefer-lowest --prefer-stable -n |
|
| 43 |
+ |
|
| 44 |
+ - name: Run Tests |
|
| 45 |
+ run: make install test |
|
| 46 |
+ |
|
| 47 |
+ - name: Fix code coverage paths |
|
| 48 |
+ run: | |
|
| 49 |
+ if [ -f "coverage.xml" ]; then |
|
| 50 |
+ sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml |
|
| 51 |
+ fi |
|
| 52 |
+ |
|
| 53 |
+ - name: Install SonarCloud scanner and run analysis |
|
| 54 |
+ uses: SonarSource/sonarcloud-github-action@master |
|
| 55 |
+ if: (github.event_name == 'pull_request' || github.ref_type == 'branch') && !github.event.pull_request.head.repo.fork && matrix.php == '8.1' && matrix.dependencies == 'highest' |
|
| 56 |
+ env: |
|
| 57 |
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
|
| 58 |
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
| 59 |
+ |
|
| 60 |
+ deploy: |
|
| 61 |
+ name: Deploy |
|
| 62 |
+ if: success() && github.ref_type == 'tag' |
|
| 63 |
+ needs: [ test ] |
|
| 64 |
+ runs-on: ubuntu-latest |
|
| 65 |
+ steps: |
|
| 66 |
+ - name: Checkout twilio-php |
|
| 67 |
+ uses: actions/checkout@v2 |
|
| 68 |
+ with: |
|
| 69 |
+ fetch-depth: 0 |
|
| 70 |
+ |
|
| 71 |
+ - name: Install dependencies |
|
| 72 |
+ run: composer install |
|
| 73 |
+ |
|
| 74 |
+ - name: Login to Docker Hub |
|
| 75 |
+ uses: docker/login-action@v1 |
|
| 76 |
+ with: |
|
| 77 |
+ username: ${{ secrets.DOCKER_USERNAME }}
|
|
| 78 |
+ password: ${{ secrets.DOCKER_AUTH_TOKEN }}
|
|
| 79 |
+ |
|
| 80 |
+ # The expression strips off the shortest match from the front of the string to yield just the tag name as the output |
|
| 81 |
+ - name: Get tagged version |
|
| 82 |
+ run: echo "GITHUB_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
| 83 |
+ |
|
| 84 |
+ - name: Create GitHub Release |
|
| 85 |
+ uses: sendgrid/dx-automator/actions/release@main |
|
| 86 |
+ env: |
|
| 87 |
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
| 88 |
+ |
|
| 89 |
+ - name: Build & Push docker image |
|
| 90 |
+ run: make docker-build docker-push |
|
| 91 |
+ |
|
| 92 |
+ - name: Submit metric to Datadog |
|
| 93 |
+ uses: sendgrid/dx-automator/actions/datadog-release-metric@main |
|
| 94 |
+ env: |
|
| 95 |
+ DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
|
|
| 96 |
+ |
|
| 97 |
+ notify-on-failure: |
|
| 98 |
+ name: Slack notify on failure |
|
| 99 |
+ if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
|
| 100 |
+ needs: [ test, deploy ] |
|
| 101 |
+ runs-on: ubuntu-latest |
|
| 102 |
+ steps: |
|
| 103 |
+ - uses: rtCamp/action-slack-notify@v2 |
|
| 104 |
+ env: |
|
| 105 |
+ SLACK_COLOR: failure |
|
| 106 |
+ SLACK_ICON_EMOJI: ':github:' |
|
| 107 |
+ SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
|
|
| 108 |
+ SLACK_TITLE: Action Failure - ${{ github.repository }}
|
|
| 109 |
+ SLACK_USERNAME: GitHub Actions |
|
| 110 |
+ SLACK_MSG_AUTHOR: twilio-dx |
|
| 111 |
+ SLACK_FOOTER: Posted automatically using GitHub Actions |
|
| 112 |
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
|
| 113 |
+ MSG_MINIMAL: true |