From 6782cb21a7d5c1e4aafd383c408df266b4bca33a Mon Sep 17 00:00:00 2001 From: Jonathan Kao Date: Mon, 4 Apr 2022 00:28:48 -0400 Subject: [PATCH 1/4] feat(kraken): push to kube-manifests repository --- cdk/kraken/src/deploy.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/cdk/kraken/src/deploy.ts b/cdk/kraken/src/deploy.ts index 2b8de2c3..1ec90371 100644 --- a/cdk/kraken/src/deploy.ts +++ b/cdk/kraken/src/deploy.ts @@ -40,6 +40,20 @@ export class DeployJob extends CheckoutJob { runsOn: 'ubuntu-latest', if: `github.ref == 'refs/heads/${fullConfig.defaultBranch}'`, steps: [ + { + name: 'Checkout kube-manifests', + uses: 'actions/checkout@v2', + with: { + repository: 'pennlabs/kube-manifests', + token: '${{ secrets.BOT_GITHUB_PAT }}', + path: 'kube-manifests', + } + }, + { + name: 'Configure git', + run: dedent`git config --global user.name github-actions + git config --global user.email github-actions[bot]@users.noreply.github.com"` + }, { id: 'synth', name: 'Synth cdk8s manifests', @@ -60,21 +74,14 @@ export class DeployJob extends CheckoutJob { }, }, { - name: 'Deploy', - run: dedent`aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl - - # get repo name from synth step - RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} - - # Deploy - kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate - kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME`, - env: { - AWS_ACCOUNT_ID: '${{ secrets.AWS_ACCOUNT_ID }}', - AWS_ACCESS_KEY_ID: '${{ secrets.GH_AWS_ACCESS_KEY_ID }}', - AWS_SECRET_ACCESS_KEY: '${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}', - }, - }, + name: 'Push to kube-manifests repository', + run: dedent`cd kube-manifests + mkdir -p \${{ github.repository }} + cp -r ../k8s/dist/ \${{ github.repository }} + git add \${{ github.repository }} + git commit -m "chore(k8s): deploy $RELEASE_NAME" + git push` + } ], ...overrides, }); From 0547c72dccc24c44d9b6646dade4e528cb15bdca Mon Sep 17 00:00:00 2001 From: Jonathan Kao Date: Sat, 16 Apr 2022 10:49:46 -0400 Subject: [PATCH 2/4] fix: add var name --- cdk/kraken/src/deploy.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cdk/kraken/src/deploy.ts b/cdk/kraken/src/deploy.ts index 144ad09a..0191f11d 100644 --- a/cdk/kraken/src/deploy.ts +++ b/cdk/kraken/src/deploy.ts @@ -82,6 +82,10 @@ export class DeployJob extends CheckoutJob { run: dedent`cd kube-manifests mkdir -p \${{ github.repository }} cp -r ../k8s/dist/ \${{ github.repository }} + + # get repo name from synth step + RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} + git add \${{ github.repository }} git commit -m "chore(k8s): deploy $RELEASE_NAME" git push` From bf486bfdd60da667d36038ee64676683ecebaa22 Mon Sep 17 00:00:00 2001 From: Jonathan Kao Date: Sat, 16 Apr 2022 10:51:38 -0400 Subject: [PATCH 3/4] fix: temporarily add back eks deploy --- cdk/kraken/src/deploy.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cdk/kraken/src/deploy.ts b/cdk/kraken/src/deploy.ts index 0191f11d..49d47802 100644 --- a/cdk/kraken/src/deploy.ts +++ b/cdk/kraken/src/deploy.ts @@ -89,7 +89,21 @@ export class DeployJob extends CheckoutJob { git add \${{ github.repository }} git commit -m "chore(k8s): deploy $RELEASE_NAME" git push` - } + }, + { + name: "Deploy", + run: dedent`aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl + # get repo name from synth step + RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} + # Deploy + kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate + kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME`, + env: { + AWS_ACCOUNT_ID: "${{ secrets.AWS_ACCOUNT_ID }}", + AWS_ACCESS_KEY_ID: "${{ secrets.GH_AWS_ACCESS_KEY_ID }}", + AWS_SECRET_ACCESS_KEY: "${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}", + }, + }, ], ...overrides, }); From 34bd9afcd7227992dfa9b89a0496c03a2c0392d2 Mon Sep 17 00:00:00 2001 From: Jonathan Kao Date: Sat, 16 Apr 2022 10:57:20 -0400 Subject: [PATCH 4/4] chore: update snapshots --- .../test/__snapshots__/custom.test.ts.snap | 29 ++++++++++- .../labs-application.test.ts.snap | 48 +++++++++++++++++-- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/cdk/kraken/test/__snapshots__/custom.test.ts.snap b/cdk/kraken/test/__snapshots__/custom.test.ts.snap index 06ad22a7..016dbc31 100644 --- a/cdk/kraken/test/__snapshots__/custom.test.ts.snap +++ b/cdk/kraken/test/__snapshots__/custom.test.ts.snap @@ -16,6 +16,20 @@ Object { Object { "uses": "actions/checkout@v2", }, + Object { + "name": "Checkout kube-manifests", + "uses": "actions/checkout@v2", + "with": Object { + "path": "kube-manifests", + "repository": "pennlabs/kube-manifests", + "token": "\${{ secrets.BOT_GITHUB_PAT }}", + }, + }, + Object { + "name": "Configure git", + "run": "git config --global user.name github-actions +git config --global user.email github-actions[bot]@users.noreply.github.com\\"", + }, Object { "env": Object { "AWS_ACCOUNT_ID": "\${{ secrets.AWS_ACCOUNT_ID }}", @@ -34,6 +48,19 @@ export RELEASE_NAME=\${REPOSITORY#*/} echo \\"::set-output name=RELEASE_NAME::$RELEASE_NAME\\" yarn build", + }, + Object { + "name": "Push to kube-manifests repository", + "run": "cd kube-manifests +mkdir -p \${{ github.repository }} +cp -r ../k8s/dist/ \${{ github.repository }} + +# get repo name from synth step +RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} + +git add \${{ github.repository }} +git commit -m \\"chore(k8s): deploy $RELEASE_NAME\\" +git push", }, Object { "env": Object { @@ -43,10 +70,8 @@ yarn build", }, "name": "Deploy", "run": "aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl - # get repo name from synth step RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} - # Deploy kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME", diff --git a/cdk/kraken/test/__snapshots__/labs-application.test.ts.snap b/cdk/kraken/test/__snapshots__/labs-application.test.ts.snap index 64c197a1..c41d44af 100644 --- a/cdk/kraken/test/__snapshots__/labs-application.test.ts.snap +++ b/cdk/kraken/test/__snapshots__/labs-application.test.ts.snap @@ -137,6 +137,16 @@ jobs: if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v2 + - name: Checkout kube-manifests + uses: actions/checkout@v2 + with: + repository: pennlabs/kube-manifests + token: \${{ secrets.BOT_GITHUB_PAT }} + path: kube-manifests + - name: Configure git + run: |- + git config --global user.name github-actions + git config --global user.email github-actions[bot]@users.noreply.github.com\\" - id: synth name: Synth cdk8s manifests run: |- @@ -154,13 +164,23 @@ jobs: GIT_SHA: \${{ github.sha }} REPOSITORY: \${{ github.repository }} AWS_ACCOUNT_ID: \${{ secrets.AWS_ACCOUNT_ID }} - - name: Deploy + - name: Push to kube-manifests repository run: |- - aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl + cd kube-manifests + mkdir -p \${{ github.repository }} + cp -r ../k8s/dist/ \${{ github.repository }} # get repo name from synth step RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} + git add \${{ github.repository }} + git commit -m \\"chore(k8s): deploy $RELEASE_NAME\\" + git push + - name: Deploy + run: |- + aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl + # get repo name from synth step + RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} # Deploy kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME @@ -383,6 +403,16 @@ jobs: if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v2 + - name: Checkout kube-manifests + uses: actions/checkout@v2 + with: + repository: pennlabs/kube-manifests + token: \${{ secrets.BOT_GITHUB_PAT }} + path: kube-manifests + - name: Configure git + run: |- + git config --global user.name github-actions + git config --global user.email github-actions[bot]@users.noreply.github.com\\" - id: synth name: Synth cdk8s manifests run: |- @@ -400,13 +430,23 @@ jobs: GIT_SHA: \${{ github.sha }} REPOSITORY: \${{ github.repository }} AWS_ACCOUNT_ID: \${{ secrets.AWS_ACCOUNT_ID }} - - name: Deploy + - name: Push to kube-manifests repository run: |- - aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl + cd kube-manifests + mkdir -p \${{ github.repository }} + cp -r ../k8s/dist/ \${{ github.repository }} # get repo name from synth step RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} + git add \${{ github.repository }} + git commit -m \\"chore(k8s): deploy $RELEASE_NAME\\" + git push + - name: Deploy + run: |- + aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::\${AWS_ACCOUNT_ID}:role/kubectl + # get repo name from synth step + RELEASE_NAME=\${{ steps.synth.outputs.RELEASE_NAME }} # Deploy kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME