|
| 1 | +name: OIDC Integration Test |
| 2 | +# This workflow tests the setup-jfrog-cli GitHub Action's OpenID Connect integration across OSes and CLI versions. |
| 3 | +# It ensures backward compatibility with older CLI versions and validates step outputs and connectivity. |
| 4 | +# CLI versions used: |
| 5 | +# - 2.74.1: Does not support `jf eot` command, validates manual fallback logic. |
| 6 | +# - 2.75.0: Introduced native OIDC token exchange. |
| 7 | +# - Latest: Ensures ongoing compatibility with the most recent CLI build. |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + # Triggers the workflow on labeled PRs only. |
| 14 | + pull_request_target: |
| 15 | + types: [ labeled ] |
| 16 | +# Ensures that only the latest commit is running for each PR at a time. |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +permissions: |
| 22 | + id-token: write |
| 23 | + contents: read |
| 24 | + |
| 25 | +jobs: |
| 26 | + oidc-test: |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + os: [ ubuntu, macos, windows ] |
| 31 | + cli-version: [ '2.74.1', '2.75.0','latest' ] |
| 32 | + runs-on: ${{ matrix.os }}-latest |
| 33 | + name: OIDC Test - ${{ matrix.cli-version }} on ${{ matrix.os }} |
| 34 | + env: |
| 35 | + JFROG_CLI_LOG_LEVEL: DEBUG |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout Repository |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + ref: ${{ github.event.pull_request.head.sha }} |
| 42 | + |
| 43 | + # Setup OIDC platform integration |
| 44 | + - name: Generate unique OIDC provider name |
| 45 | + id: gen-oidc |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + cli_version="${{ matrix.cli-version }}" && cli_version="${cli_version//./-}" |
| 49 | + echo "oidc_provider_name=oidc-integration-${cli_version}-${{ matrix.os }}-$(date +%s)" >> "$GITHUB_OUTPUT" |
| 50 | +
|
| 51 | + - name: Create OpenID Connect integration |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + curl -X POST "${{ secrets.JFROG_PLATFORM_URL }}/access/api/v1/oidc" \ |
| 55 | + -H "Content-Type: application/json" \ |
| 56 | + -H "Authorization: Bearer ${{ secrets.JFROG_PLATFORM_RT_TOKEN }}" \ |
| 57 | + -d '{ |
| 58 | + "name": "${{ steps.gen-oidc.outputs.oidc_provider_name }}", |
| 59 | + "issuer_url": "https://token.actions.githubusercontent.com", |
| 60 | + "provider_type": "GitHub", |
| 61 | + "enable_permissive_configuration": "true", |
| 62 | + "description": "Test configuration for CLI version ${{ matrix.cli-version }}" |
| 63 | + }' |
| 64 | +
|
| 65 | + - name: Create OIDC Identity Mapping |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + curl -X POST "${{ secrets.JFROG_PLATFORM_URL }}/access/api/v1/oidc/${{ steps.gen-oidc.outputs.oidc_provider_name }}/identity_mappings" \ |
| 69 | + -H 'Content-Type: application/json' \ |
| 70 | + -H "Authorization: Bearer ${{ secrets.JFROG_PLATFORM_RT_TOKEN }}" \ |
| 71 | + -d '{ |
| 72 | + "name": "oidc-test-mapping", |
| 73 | + "priority": "1", |
| 74 | + "claims": { |
| 75 | + "repository": "${{ github.repository_owner }}/setup-jfrog-cli" |
| 76 | + }, |
| 77 | + "token_spec": { |
| 78 | + "scope": "applied-permissions/groups:readers", |
| 79 | + "expires_in": 30 |
| 80 | + } |
| 81 | + }' |
| 82 | +
|
| 83 | + # Setup |
| 84 | + - name: Setup JFrog CLI |
| 85 | + id: setup-jfrog-cli |
| 86 | + uses: ./ |
| 87 | + env: |
| 88 | + JF_URL: ${{ secrets.JFROG_PLATFORM_URL }} |
| 89 | + with: |
| 90 | + version: ${{ matrix.cli-version }} |
| 91 | + oidc-provider-name: ${{ steps.gen-oidc.outputs.oidc_provider_name }} |
| 92 | + |
| 93 | + # validate successful OIDC configuration |
| 94 | + - name: Test JFrog CLI connectivity |
| 95 | + run: jf rt ping |
| 96 | + |
| 97 | + # Validate step outputs |
| 98 | + - name: Validate user output |
| 99 | + shell: bash |
| 100 | + run: test -n "${{ steps.setup-jfrog-cli.outputs.oidc-user }}" |
| 101 | + |
| 102 | + - name: Validate token output |
| 103 | + shell: bash |
| 104 | + run: test -n "${{ steps.setup-jfrog-cli.outputs.oidc-token }}" |
| 105 | + |
| 106 | + # Cleanup |
| 107 | + - name: Delete OIDC integration |
| 108 | + shell: bash |
| 109 | + if: always() |
| 110 | + run: | |
| 111 | + curl -X DELETE "${{ secrets.JFROG_PLATFORM_URL }}/access/api/v1/oidc/${{ steps.gen-oidc.outputs.oidc_provider_name }}" \ |
| 112 | + -H "Authorization: Bearer ${{ secrets.JFROG_PLATFORM_RT_TOKEN }}" |
0 commit comments