|
1 | 1 | # alibabacloud-oidc-auth |
| 2 | + |
2 | 3 | GitHub Action for authenticating to Alibaba Cloud with GitHub Actions OIDC tokens. |
| 4 | + |
| 5 | +## Inputs |
| 6 | + |
| 7 | +* `role-arn-to-assume`: (Required) The arn of Ram role. |
| 8 | +* `oidc-provider-arn`: (Required) The arn of OIDC IdP. |
| 9 | +* `export-environment-variables`: (Optional) Export common environment variables. The default value is: `false` |
| 10 | +* `set-outputs`: (Optional) Setting action outputs. The default value is: `false` |
| 11 | +* `audience`: (Optional) The audience (aud) parameter in GitHub's generated OIDC |
| 12 | + token. The default value is: `actions.github.com` |
| 13 | +* `role-duration-seconds`: (Optional) The validity period of the STS token. The default value is: `3600` |
| 14 | +* `role-session-name`: (Optional) The custom name of the role session. The default value is: `github-action` |
| 15 | +* `region`: (Optional) The region id of STS endpoint. The default value is: `ap-southeast-1` |
| 16 | + |
| 17 | +## Outputs |
| 18 | + |
| 19 | +* `access-key-id`: (Optional) The AccessKey ID. |
| 20 | +* `access-key-secret`: (Optional) The AccessKey secret. |
| 21 | +* `security-token`: (Optional) The STS token. |
| 22 | + |
| 23 | + |
| 24 | +## Example Usage |
| 25 | + |
| 26 | +```yaml |
| 27 | +jobs: |
| 28 | + job-id: |
| 29 | + # ... |
| 30 | + permissions: |
| 31 | + id-token: write # This is required for requesting the JWT |
| 32 | + steps: |
| 33 | + - name: get credentials |
| 34 | + id: get-credentials |
| 35 | + uses: 'mozillazg/alibabacloud-oidc-auth@v1' |
| 36 | + with: |
| 37 | + role-arn-to-assume: '${{ secrets.ALIBABA_CLOUD_RAM_ROLE_ARN }}' |
| 38 | + oidc-provider-arn: '${{ secrets.ALIBABA_CLOUD_RAM_OIDC_ARN }}' |
| 39 | + export-environment-variables: 'true' |
| 40 | + - run: | |
| 41 | + aliyun sts GetCallerIdentity |
| 42 | +``` |
| 43 | +
|
| 44 | +Or |
| 45 | +
|
| 46 | +```yaml |
| 47 | +jobs: |
| 48 | + job-id: |
| 49 | + # ... |
| 50 | + permissions: |
| 51 | + id-token: write # This is required for requesting the JWT |
| 52 | + steps: |
| 53 | + - name: get credentials |
| 54 | + id: get-credentials |
| 55 | + uses: 'mozillazg/alibabacloud-oidc-auth@v1' |
| 56 | + with: |
| 57 | + role-arn-to-assume: '${{ secrets.ALIBABA_CLOUD_RAM_ROLE_ARN }}' |
| 58 | + oidc-provider-arn: '${{ secrets.ALIBABA_CLOUD_RAM_OIDC_ARN }}' |
| 59 | + set-outputs: 'true' |
| 60 | + - run: | |
| 61 | + ossutil64 --access-key-id ${{ steps.get-credentials.outputs.access-key-id }} \ |
| 62 | + --access-key-secret ${{ steps.get-credentials.outputs.access-key-secret }} \ |
| 63 | + --sts-token ${{ steps.get-credentials.outputs.security-token }} --mode StsToken \ |
| 64 | + --endpoint oss-ap-southeast-1.aliyuncs.com \ |
| 65 | + stat oss://test-bucket |
| 66 | +``` |
| 67 | +
|
| 68 | +## RAM Configuration |
| 69 | +
|
| 70 | +1. Configure an [OIDC IdP](https://www.alibabacloud.com/help/en/resource-access-management/latest/manage-an-oidc-idp?spm=a2c63.p38356.0.0.3d076b9do9jEJr#section-hqp-6mi-g84) for the auth method: |
| 71 | + * **IdP URL**: `https://token.actions.githubusercontent.com` |
| 72 | + * **Client ID**: `actions.github.com` |
| 73 | +2. Configure a [RAM role for an OIDC IdP](https://www.alibabacloud.com/help/en/resource-access-management/latest/create-a-ram-role-for-a-trusted-idp#section-mra-74d-14w) to assume: |
| 74 | + * **oidc:aud**: `actions.github.com` |
| 75 | + * **oidc:sub**: match on [GitHub subject claims](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims). |
| 76 | + * match branch: `repo:<orgName/repoName>:ref:refs/heads/<branchName>` |
| 77 | + * match tag: `repo:<orgName/repoName>:ref:refs/tags/<tagName>` |
| 78 | + |
0 commit comments