Skip to content

Replace Slack notification action and harden action refs #340

Replace Slack notification action and harden action refs

Replace Slack notification action and harden action refs #340

Workflow file for this run

# This workflow will build and test a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: CI
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- unlabeled
jobs:
Java:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
strategy:
matrix:
java: ['8','11']
runs-on: ubuntu-latest
env:
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
# This allows us to test Smart CDN Signatures against the Node SDK reference
# implementation for parity.
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew assemble
- name: Run Tests
run: ./gradlew check
- name: Upload coverage to Codecov
if: matrix.java == '11'
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slack-on-failure:
needs: [Java]
if: failure() && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Send Slack notification
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_TEXT: >-
${{ github.workflow }} failed for ${{ github.repository }} on ${{ github.ref_name }}:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
node -e "process.stdout.write(JSON.stringify({ text: process.env.SLACK_TEXT }))" |
curl --fail-with-body -X POST -H 'Content-type: application/json' --data-binary @- "$SLACK_WEBHOOK_URL"