Skip to content

Commit fc67534

Browse files
authored
chore: replace CDK_REPO_TOKEN PAT with GitHub App token in e2e workflows (#1201)
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.
1 parent 1402057 commit fc67534

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/e2e-tests-full.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ jobs:
5757
parse-json-secrets: true
5858
- run: npm ci
5959
- run: npm run build
60+
- name: Generate GitHub App Token
61+
if: matrix.cdk-source == 'main'
62+
id: app-token
63+
uses: actions/create-github-app-token@v1
64+
with:
65+
app-id: ${{ vars.APP_ID }}
66+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
67+
owner: aws
6068
- name: Build CDK package from main
6169
if: matrix.cdk-source == 'main'
6270
run: |
@@ -67,7 +75,7 @@ jobs:
6775
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
6876
echo "CDK_TARBALL=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_ENV"
6977
env:
70-
CDK_REPO_TOKEN: ${{ secrets.CDK_REPO_TOKEN }}
78+
CDK_REPO_TOKEN: ${{ steps.app-token.outputs.token }}
7179
CDK_REPO: ${{ secrets.CDK_REPO_NAME }}
7280
- name: Install CLI globally
7381
run: npm install -g "$(npm pack | tail -1)"

.github/workflows/e2e-tests.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,15 @@ jobs:
7979
E2E,${{ secrets.E2E_SECRET_ARN }}
8080
parse-json-secrets: true
8181

82+
- name: Generate GitHub App Token
83+
id: app-token
84+
uses: actions/create-github-app-token@v1
85+
with:
86+
app-id: ${{ vars.APP_ID }}
87+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
88+
owner: aws
8289
# Build @aws/agentcore-cdk from source for cross-package testing.
83-
# Requires secrets: CDK_REPO_NAME (org/repo), CDK_REPO_TOKEN (fine-grained PAT)
90+
# Requires secret: CDK_REPO_NAME (org/repo). Token is generated by the App above.
8491
- name: Build CDK package
8592
run: |
8693
CDK_BRANCH="${{ inputs.cdk_branch || 'main' }}"
@@ -92,7 +99,7 @@ jobs:
9299
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
93100
echo "CDK_TARBALL=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_ENV"
94101
env:
95-
CDK_REPO_TOKEN: ${{ secrets.CDK_REPO_TOKEN }}
102+
CDK_REPO_TOKEN: ${{ steps.app-token.outputs.token }}
96103
CDK_REPO: ${{ secrets.CDK_REPO_NAME }}
97104

98105
- run: npm ci

0 commit comments

Comments
 (0)