diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml index dc7af3d..5bbede7 100644 --- a/.github/workflows/pr-lint.yml +++ b/.github/workflows/pr-lint.yml @@ -3,13 +3,22 @@ on: pull_request_target: types: [ opened, edited, synchronize, reopened ] +permissions: + contents: read + pull-requests: read + jobs: validate: name: Validate title - runs-on: ubuntu-latest + runs-on: ubuntu-x64 steps: - - uses: amannn/action-semantic-pull-request@v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: twilio/sdk-actions/semantic-pr-title@09631bfa50f14d276170d45bc4f49a80da201cc6 # main @ 09631bf — sdk-actions#10; repin to the v1.1.0 tag once cut with: - types: chore docs fix feat test - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + types: | + chore + docs + fix + feat + misc + test diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml new file mode 100644 index 0000000..8aa1b62 --- /dev/null +++ b/.github/workflows/test-and-deploy.yml @@ -0,0 +1,86 @@ +name: Test and Deploy +on: + push: + branches: [ '*' ] + tags: [ '*' ] + pull_request: + branches: [ main ] + schedule: + # Run automatically at 8AM PST Monday-Friday + - cron: '0 15 * * 1-5' + workflow_dispatch: + +jobs: + test: + name: Test - Go ${{ matrix.go }} + runs-on: ubuntu-x64 + if: github.repository_owner == 'sendgrid' + timeout-minutes: 20 + permissions: + contents: read + strategy: + fail-fast: false + matrix: + go: [ '1.22', '1.23', '1.24', '1.25' ] + steps: + - name: Checkout rest + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - name: Setup Go environment + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + with: + go-version: ${{ matrix.go }} + + - name: Set Go env vars + run: | + echo "GOPATH=$HOME" >> $GITHUB_ENV + echo "GOBIN=$HOME/bin" >> $GITHUB_ENV + echo "GO111MODULE=off" >> $GITHUB_ENV + + - name: Run Tests + run: make test + + deploy: + name: Deploy + if: success() && github.ref_type == 'tag' && github.repository_owner == 'sendgrid' + needs: [ test ] + runs-on: ubuntu-x64 + environment: + name: production + url: https://pkg.go.dev/github.com/sendgrid/rest + permissions: + contents: write # required for creating GitHub Release + steps: + - name: Checkout rest + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + # The release action verifies refs/tags/ in the local clone. + fetch-depth: 0 + + - name: Create GitHub Release + uses: twilio/sdk-actions/github-release@9b1c3222c9ffe38aadedb11c5b9f5a172b5e9951 # v1 + with: + changelog-file: CHANGELOG.md + +# - name: Submit metric to Datadog +# uses: sendgrid/dx-automator/actions/datadog-release-metric@08b601b726671445abc798ed59881766ec8fefc6 # main +# env: +# DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} + +# notify-on-failure: +# name: Slack notify on failure +# if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') +# needs: [ test, deploy ] +# runs-on: ubuntu-x64 +# steps: +# - uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 +# env: +# SLACK_COLOR: failure +# SLACK_ICON_EMOJI: ':github:' +# 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) }} +# SLACK_TITLE: Action Failure - ${{ github.repository }} +# SLACK_USERNAME: GitHub Actions +# SLACK_MSG_AUTHOR: twilio-dx +# SLACK_FOOTER: Posted automatically using GitHub Actions +# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} +# MSG_MINIMAL: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 2208ae5..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Test and Deploy -on: - push: - branches: [ '*' ] - tags: [ '*' ] - pull_request: - branches: [ main ] - schedule: - # Run automatically at 8AM PST Monday-Friday - - cron: '0 15 * * 1-5' - workflow_dispatch: - -jobs: - test: - name: Build & Test - runs-on: ubuntu-latest - timeout-minutes: 20 - strategy: - matrix: - go: [ '1.14', '1.15', '1.16', '1.17' ] - steps: - - name: Checkout rest - uses: actions/checkout@v2 - - - name: Setup Go environment - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go }} - - - name: Set Go env vars - run: | - echo "GOPATH=$HOME" >> $GITHUB_ENV - echo "GOBIN=$HOME/bin" >> $GITHUB_ENV - echo "GO111MODULE=off" >> $GITHUB_ENV - - - name: Run Tests - run: make test - - deploy: - name: Deploy - if: success() && github.ref_type == 'tag' - needs: [ test ] - runs-on: ubuntu-latest - steps: - - name: Checkout rest - uses: actions/checkout@v2 - - - name: Create GitHub Release - uses: sendgrid/dx-automator/actions/release@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Submit metric to Datadog - uses: sendgrid/dx-automator/actions/datadog-release-metric@main - env: - DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} - - notify-on-failure: - name: Slack notify on failure - 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('Test *{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 - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - MSG_MINIMAL: true