This guide explains how to configure GitHub Actions OIDC (OpenID Connect) for running E2E tests against Alibaba Cloud without storing long-lived AK/SK credentials.
GitHub Actions ──OIDC token──> Alibaba Cloud RAM (OIDC Provider)
│
▼
STS AssumeRoleWithOIDC
│
▼
Temporary AK/SK/SecurityToken
│
▼
E2E tests use temp creds
- GitHub Actions generates an OIDC token containing repository and workflow metadata.
- The
aliyun/configure-aliyun-credentials-actionexchanges that token with Alibaba Cloud STS. - STS returns temporary credentials (valid for 1 hour) scoped to a specific RAM Role.
- E2E tests use those credentials — no permanent secrets stored anywhere.
- Alibaba Cloud account with RAM admin access
- GitHub repository admin access (to configure secrets)
- Go to RAM Console > SSO Management > OIDC
- Click Create OIDC Provider
- Fill in the form:
| Field | Value |
|---|---|
| Provider Name | github-actions |
| Issuer URL | https://token.actions.githubusercontent.com |
| Client ID (Audience) | sts.aliyuncs.com |
| Description | GitHub Actions OIDC for agentrun-sdk e2e tests |
- Click OK to create.
- Copy the Provider ARN, it looks like:
acs:ram::<ACCOUNT_ID>:oidc-provider/github-actions
- Go to RAM Console > Identities > Roles
- Click Create Role > IdP > OIDC
- Fill in the form:
| Field | Value |
|---|---|
| Role Name | github-actions-e2e |
| Select OIDC Provider | github-actions (created in Step 1) |
| Condition | See trust policy below |
- Use this Trust Policy (edit the role after creation if the console doesn't allow full customization):
{
"Statement": [
{
"Action": "sts:AssumeRoleWithOIDC",
"Condition": {
"StringEquals": {
"oidc:aud": "sts.aliyuncs.com"
},
"StringLike": {
"oidc:sub": "repo:Serverless-Devs/agentrun-sdk-python:*"
}
},
"Effect": "Allow",
"Principal": {
"Federated": [
"acs:ram::<ACCOUNT_ID>:oidc-provider/github-actions"
]
}
}
],
"Version": "1"
}Replace
<ACCOUNT_ID>with your Alibaba Cloud account ID.The
oidc:subcondition restricts access to this specific repository. You can narrow it further:repo:Serverless-Devs/agentrun-sdk-python:ref:refs/heads/mainwould limit to the main branch only.
- Copy the Role ARN, it looks like:
acs:ram::<ACCOUNT_ID>:role/github-actions-e2e
The RAM Role needs permissions to call AgentRun / Function Compute APIs used by the E2E tests. Create a custom policy or attach existing ones:
Recommended minimum permissions:
AliyunFCReadOnlyAccess(read-only FC access for test verification)- A custom policy for AgentRun API operations used in tests
Example custom policy:
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": [
"fc:*"
],
"Resource": [
"acs:fc:<REGION>:<ACCOUNT_ID>:*"
]
}
]
}Adjust the
ActionandResourcescope based on what your E2E tests actually call. Principle of least privilege: grant only what the tests need.
Go to GitHub repo > Settings > Secrets and variables > Actions and add:
| Secret Name | Description | Example |
|---|---|---|
ALIBABA_CLOUD_OIDC_PROVIDER_ARN |
OIDC Provider ARN from Step 1 | acs:ram::1234567890:oidc-provider/github-actions |
ALIBABA_CLOUD_OIDC_ROLE_ARN |
RAM Role ARN from Step 2 | acs:ram::1234567890:role/github-actions-e2e |
| Secret Name | Description | Example |
|---|---|---|
AGENTRUN_ACCOUNT_ID |
Alibaba Cloud account ID | 1234567890 |
AGENTRUN_REGION |
Region for test resources | cn-hangzhou |
AGENTRUN_CONTROL_ENDPOINT |
AgentRun control API endpoint | https://agentrun.cn-hangzhou.aliyuncs.com |
AGENTRUN_DATA_ENDPOINT |
AgentRun data API endpoint | https://1234567890.agentrun-data.cn-hangzhou.aliyuncs.com |
API_KEYandAGENTRUN_TEST_WORKSPACE_IDuse hardcoded placeholders in the workflow and do not need to be configured as secrets.
- Push a commit to
mainor trigger the workflow manually via Actions > E2E Tests > Run workflow. - Check the workflow run — the "Configure Alibaba Cloud credentials (OIDC)" step should succeed.
- E2E tests should run with temporary credentials.
- Verify the OIDC Provider issuer URL is exactly
https://token.actions.githubusercontent.com - Verify the Role trust policy
oidc:submatches your repo:repo:Serverless-Devs/agentrun-sdk-python:* - Check the audience is
sts.aliyuncs.com
- The RAM Role needs the right policies attached (Step 3)
- Check if the region in the policy matches
AGENTRUN_REGION
- This is intentional: fork PRs cannot access OIDC secrets
- Only PRs from the same repo, pushes to main, and manual triggers run e2e