chore: replace CDK_REPO_TOKEN PAT with GitHub App token#1201
chore: replace CDK_REPO_TOKEN PAT with GitHub App token#1201aidandaly24 wants to merge 1 commit into
Conversation
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Nice switch from a long-lived PAT to a short-lived GitHub App token — the approach is sound and matches the pattern already used in ci-failure-issue.yml / agent-restricted.yml. I flagged one issue that I believe will cause the E2E tests to fail on first run; see the inline comment.
| uses: actions/create-github-app-token@v1 | ||
| with: | ||
| app-id: ${{ vars.APP_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} |
There was a problem hiding this comment.
Token will be scoped to the wrong repository — CDK clone will fail
actions/create-github-app-token has this default behavior (from its action.yml):
repositories: Comma or newline-separated list of repositories to grant the token access to (defaults to current repository ifowneris unset)
Because neither owner nor repositories is set here, the generated token is scoped to aws/agentcore-cli only. The subsequent step then tries to clone a different repo (${{ secrets.CDK_REPO_NAME }}) using that token:
git clone --depth 1 "https://x-access-token:${CDK_REPO_TOKEN}@github.com/${CDK_REPO}.git" /tmp/cdk-repoThat clone will fail with 404 / auth error because the installation token has no access to the CDK repo, regardless of whether the agentcore-devx-automation App is installed on it. The existing usages (agent-restricted.yml, ci-failure-issue.yml) only act on the current repo, so they don't expose this issue.
Fix options:
-
Explicitly scope to the CDK repo. Store the CDK repo name as a
vars.CDK_REPO_NAME(or split the existingorg/reposecret — therepositoriesinput wants just the repo name, notorg/repo) and pass:- uses: actions/create-github-app-token@v1 with: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} owner: <cdk-repo-owner> # e.g. ${{ github.repository_owner }} if same org repositories: <cdk-repo-name> # just the repo name, no owner prefix
-
Scope to both repos if you'd rather keep a single token generation step that could be reused:
with: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: | ${{ github.event.repository.name }} <cdk-repo-name>
Either way, please also verify the agentcore-devx-automation App is installed on the CDK repo with at least contents: read, and update the test plan to cover this before deleting CDK_REPO_TOKEN.
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-1201-tarball/aws-agentcore-0.13.1.tgz |
Coverage Report
|
Use actions/create-github-app-token@v1 to generate a short-lived token for cloning the CDK repo instead of the CDK_REPO_TOKEN PAT secret.
d3ea3a8 to
00e53f6
Compare
Summary
secrets.CDK_REPO_TOKEN(a fine-grained PAT) ine2e-tests.ymlande2e-tests-full.ymlwith a short-lived GitHub App tokenactions/create-github-app-token@v1with theagentcore-devx-automationapp (ID: 3637953)Secrets to Delete After Verification
CDK_REPO_TOKENTest plan