> For the complete documentation index, see [llms.txt](https://zeyad-abulaban.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zeyad-abulaban.gitbook.io/notes/devops/github-actions.md).

# GitHub Actions

## GitHub OIDC with AWS

If you’re running into issues with the **trust policy `sub` claim**, you can debug by retrieving the ID token using this workflow:

```yaml
name: id-token

on:
  workflow_dispatch:
  pull_request:
    types: [closed]
    branches: [main]

jobs:
  get-id-token:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - name: Get OIDC Token
        run: |
          ID_TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
            "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://demo" | jq -r .value)
          echo "$ID_TOKEN" | base32
```

Once you have the decoded token, check the `sub` claim and make sure it matches what your IAM role’s trust policy expects.

### Example Trust Policy

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "token.actions.githubusercontent.com:sub": [
                        "repo:<ORG>/<REPO>:ref:refs/heads/main",
                        "repo:<ORG>/<REPO>:pull_request"
                    ],
                    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
                }
            }
        }
    ]
}
```

* Replace `<ACCOUNT_ID>`, `<ORG>`, and `<REPO>` with your values.
* The `sub` claim typically follows the format:

  ```
  repo:<ORG>/<REPO>:ref:refs/heads/<BRANCH>
  ```

### References

* [StackOverflow: Error not authorized to perform `sts:AssumeRoleWithWebIdentity` during OIDC](https://stackoverflow.com/questions/78746014/error-not-authorized-to-perform-stsassumerolewithwebidentity-during-oidc-when)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://zeyad-abulaban.gitbook.io/notes/devops/github-actions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
