Skip to content

Commit 8435a43

Browse files
authored
chore: replace CDK_REPO_TOKEN PAT with GitHub App token in e2e workflows (#181)
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 617534b commit 8435a43

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ 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 }}
6067
- name: Build CDK package from main
6168
if: matrix.cdk-source == 'main'
6269
run: |
@@ -67,7 +74,7 @@ jobs:
6774
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
6875
echo "CDK_TARBALL=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_ENV"
6976
env:
70-
CDK_REPO_TOKEN: ${{ secrets.CDK_REPO_TOKEN }}
77+
CDK_REPO_TOKEN: ${{ steps.app-token.outputs.token }}
7178
CDK_REPO: ${{ secrets.CDK_REPO_NAME }}
7279
- name: Install CLI globally
7380
run: npm install -g "$(npm pack | tail -1)"

.github/workflows/e2e-tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ jobs:
7676
E2E,${{ secrets.E2E_SECRET_ARN }}
7777
parse-json-secrets: true
7878

79-
# Build @aws/agentcore-cdk from source for cross-package testing.
80-
# Requires secrets: CDK_REPO_NAME (org/repo), CDK_REPO_TOKEN (fine-grained PAT)
79+
- name: Generate GitHub App Token
80+
id: app-token
81+
uses: actions/create-github-app-token@v1
82+
with:
83+
app-id: ${{ vars.APP_ID }}
84+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
8185
- name: Build CDK package from main
8286
run: |
8387
git clone --depth 1 "https://x-access-token:${CDK_REPO_TOKEN}@github.com/${CDK_REPO}.git" /tmp/cdk-repo
@@ -87,7 +91,7 @@ jobs:
8791
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
8892
echo "CDK_TARBALL=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_ENV"
8993
env:
90-
CDK_REPO_TOKEN: ${{ secrets.CDK_REPO_TOKEN }}
94+
CDK_REPO_TOKEN: ${{ steps.app-token.outputs.token }}
9195
CDK_REPO: ${{ secrets.CDK_REPO_NAME }}
9296

9397
- run: npm ci

0 commit comments

Comments
 (0)