Repository navigation
Harden CI: Artifactory OIDC, fork-aware workflows, tightened permissions #16
This file contains hidden or 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
| name: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }} | |
| jobs: | |
| lint: | |
| name: Lint (spotless + animal-sniffer) | |
| runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '11' | |
| cache: maven | |
| - name: Artifactory OIDC | |
| if: ${{ !github.event.pull_request.head.repo.fork }} | |
| uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main | |
| with: | |
| ecosystem: maven | |
| provider-name: github-actions-segmentio | |
| - name: Spotless check | |
| run: mvn -B spotless:check | |
| - name: Animal Sniffer check | |
| # Needs the reactor compiled first: `analytics` builds against the | |
| # analytics-core SNAPSHOT, which exists nowhere until this run makes it. | |
| # `compile` rather than `package` — linting has no use for the javadoc, | |
| # source and signing plugins that packaging would drag in. | |
| run: mvn -B -DskipTests compile animal-sniffer:check | |
| test: | |
| name: Test (Java ${{ matrix.java-version }}) | |
| runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| java-version: ['11', '17', '21'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Set up JDK ${{ matrix.java-version }} | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ matrix.java-version }} | |
| cache: maven | |
| - name: Artifactory OIDC | |
| if: ${{ !github.event.pull_request.head.repo.fork }} | |
| uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main | |
| with: | |
| ecosystem: maven | |
| provider-name: github-actions-segmentio | |
| - name: Run tests | |
| run: mvn -B test | |
| build: | |
| name: Build verification | |
| runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }} | |
| needs: [lint, test] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '11' | |
| cache: maven | |
| - name: Artifactory OIDC | |
| if: ${{ !github.event.pull_request.head.repo.fork }} | |
| uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main | |
| with: | |
| ecosystem: maven | |
| provider-name: github-actions-segmentio | |
| - name: Build | |
| run: mvn -B package -DskipTests | |
| - name: Verify | |
| run: mvn -B verify -DskipTests |