.github/workflows/oidc.yml #4
This file contains 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: API Call with OIDC Authentication | |
on: | |
workflow_dispatch: # Enables manual trigger from GitHub UI | |
jobs: | |
call-api: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write # Necessary to request an OIDC token | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Obtain OIDC Token | |
id: get_oidc | |
uses: actions/oidc-client@v1 # Official action to obtain OIDC token | |
- name: Call External API | |
run: | | |
curl -X POST "https://charming-termite-surely.ngrok-free.app" \ | |
-H "Authorization: Bearer ${{ steps.get_oidc.outputs.token }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{"data": "Hello from GitHub Actions!"}' |