diff --git a/cdk/kraken/src/deploy.ts b/cdk/kraken/src/deploy.ts index 19957bf8..49d47802 100644 --- a/cdk/kraken/src/deploy.ts +++ b/cdk/kraken/src/deploy.ts @@ -45,8 +45,22 @@ export class DeployJob extends CheckoutJob { if: `github.ref == 'refs/heads/${fullConfig.defaultBranch}'`, steps: [ { - id: "synth", - name: "Synth cdk8s manifests", + 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', run: dedent`cd k8s yarn install --frozen-lockfile @@ -64,12 +78,23 @@ 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 + name: 'Push to kube-manifests repository', + 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` + }, + { + 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`, 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