Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature branch deploy #142

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eef1735
:tada: Add feature branch deploy (hopefully it works lol)
joyliu-q Jun 20, 2022
ac1d1fc
:bug: Fix
joyliu-q Jun 20, 2022
613a8c8
Merge branch 'master' of https://github.com/pennlabs/website into fea…
joyliu-q Jun 20, 2022
3da1d47
:art: new line
joyliu-q Jun 23, 2022
38b33e9
:arrow_up: Upgrade deps
joyliu-q Jun 25, 2022
c43cf58
:white_check_mark: Update constructs for CI to pass
joyliu-q Jun 25, 2022
5a9f7d6
:arrow_up: Bump kittyhawk
joyliu-q Jun 27, 2022
4f2c689
:bug: Update lockfile
joyliu-q Jun 27, 2022
d579fd4
:art: Update lockfile
joyliu-q Jun 27, 2022
ad1898f
:arrow_up: Bump kraken
joyliu-q Jun 27, 2022
0ae88e1
:art: Push image
joyliu-q Jun 27, 2022
204d399
:bug: LOL IGNORE THAT TYPO
joyliu-q Jun 28, 2022
29ee3f8
:bug: Shh
joyliu-q Jun 28, 2022
f104dba
:art: Add deployment URLs
joyliu-q Jun 28, 2022
d700b4c
:art: Custom message with pr link
joyliu-q Jun 28, 2022
83a01de
:art: [Breaks Validation] Testing Sticky Comment
joyliu-q Jun 28, 2022
6d02b7f
:art: Fix typo
joyliu-q Jun 28, 2022
7665e49
:art: [Breaks Validation] Testing Sticky Comment
joyliu-q Jun 28, 2022
791cc89
:art: Is it actually sticky
joyliu-q Jun 28, 2022
3737068
:art: Empty commit :D
joyliu-q Jun 28, 2022
f60f5d9
:art: Try again
joyliu-q Jun 29, 2022
b502620
:bug: Fix NOT FOUND CI
joyliu-q Jun 30, 2022
b9a7c37
:bug: Oops
joyliu-q Jun 30, 2022
adad38f
:art: Add arbitrary change for diff
joyliu-q Jun 30, 2022
6973503
:art: Trial
joyliu-q Jun 30, 2022
3499c67
:art: Test
joyliu-q Jun 30, 2022
9a7cc5a
:art: Attempt
joyliu-q Jun 30, 2022
587ae26
:pensive: Bruh
joyliu-q Jun 30, 2022
9730278
:art: Help
joyliu-q Jun 30, 2022
64bd842
:heavy_check_mark: Fix nuke job
joyliu-q Jun 30, 2022
28f83d0
Merge pull request #143 from pennlabs/feat/test-nuke-job
joyliu-q Jun 30, 2022
0031070
:arrow_up: Bump kraken
joyliu-q Jun 30, 2022
83a3b35
Revert "[Feature Branch Deploy] Test nuke job"
joyliu-q Jun 30, 2022
e73aab2
Merge pull request #144 from pennlabs/revert-143-feat/test-nuke-job
joyliu-q Jun 30, 2022
6d37d2c
:bug: Fix bug
joyliu-q Jun 30, 2022
8880982
Merge branch 'feat/add-feature-branch-deploy' of https://github.com/p…
joyliu-q Jun 30, 2022
8c1d006
:art: Lol
joyliu-q Jun 30, 2022
c260a86
Merge branch 'master' into feat/add-feature-branch-deploy
joyliu-q Jan 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions .github/cdk/main.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
import { Construct } from "constructs";
import { App, Stack, Workflow } from "cdkactions";
import { DeployJob, ReactProject } from "@pennlabs/kraken";
import { Construct } from 'constructs'
import { App, Stack, Workflow } from 'cdkactions'
import { DeployJob, NukeJob, ReactProject } from '@pennlabs/kraken'

export class WebsiteStack extends Stack {
constructor(scope: Construct, name: string) {
super(scope, name);
super(scope, name)
const workflow = new Workflow(this, 'build-and-deploy', {
name: 'Build and Deploy',
on: 'push',
});
})

const websiteJob = new ReactProject(workflow, {
imageName: 'website',
});
publishProps: {
push: "${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/feat/') == true }}"
}
})

new DeployJob(workflow, {}, {
needs: [websiteJob.publishJobId]
});
// Add Production Deploy
new DeployJob(
workflow,
{
},
{
needs: [websiteJob.publishJobId],
},
)

// Add Feature Branch Deploy to Original Workflow
new DeployJob(
workflow,
{
deployToFeatureBranch: true,
deploymentUrls: ["pennlabs.org"]
},
{
needs: [websiteJob.publishJobId],
},
)

// Create Feature Branch Nuke Worflow
const featureBranchNukeWorkflow = new Workflow(
this,
'feature-branch-nuke',
{
name: 'Feature Branch Nuke',
on: { pullRequest: { types: ['closed'] } },
},
)
new NukeJob(featureBranchNukeWorkflow, {}, {})
}
}

const app = new App();
new WebsiteStack(app, 'website');
app.synth();
const app = new App()
new WebsiteStack(app, 'website')
app.synth()
2 changes: 1 addition & 1 deletion .github/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"upgrade-cdk": "yarn upgrade cdkactions@latest cdkactions-cli@latest"
},
"dependencies": {
"@pennlabs/kraken": "^0.8.6",
"@pennlabs/kraken": "^0.8.9",
"cdkactions": "^0.2.3",
"constructs": "^3.2.109"
},
Expand Down
106 changes: 48 additions & 58 deletions .github/cdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
# yarn lockfile v1


"@pennlabs/kraken@^0.8.6":
version "0.8.6"
resolved "https://registry.yarnpkg.com/@pennlabs/kraken/-/kraken-0.8.6.tgz#79a9d10bed36b699c526556cd69b6d81341847d1"
integrity sha512-aBblQa/661DJ2GP3Dq1KEzCZ72ZV/Jw7z4HNZoWPxGWn+tSPwvaPkSNDpK7tT+nJmu427giGU8DLyciU79hKbA==
"@pennlabs/kraken@^0.8.9":
version "0.8.9"
resolved "https://registry.yarnpkg.com/@pennlabs/kraken/-/kraken-0.8.9.tgz#0b72e5e6dc96176242358c72d789f14e3a4ff34b"
integrity sha512-EMMdunVKTHRfdQOFBK9tzxFaPJwHDExEzFkUwVJnRypFu6kY/61j2CIoDOAjxkiIZaKbbr6NCpJL2iuC6D12/A==
dependencies:
cdkactions "^0.2.3"
constructs "^3.2.80"
constructs "^3.2.109"
ts-dedent "^2.2.0"

"@types/node@^14.14.22":
version "14.14.22"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==
version "14.18.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.21.tgz#0155ee46f6be28b2ff0342ca1a9b9fd4468bef41"
integrity sha512-x5W9s+8P4XteaxT/jKF0PSb7XEvo5VmqEWgsMlyeY4ZlLK8I6aH6g5TPPyDlLAep+GYf4kefb7HFyc7PAO3m+Q==

ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==

ansi-styles@^4.0.0:
version "4.3.0"
Expand Down Expand Up @@ -75,14 +75,9 @@ color-name@~1.1.4:
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

constructs@^3.2.109:
version "3.2.113"
resolved "https://registry.yarnpkg.com/constructs/-/constructs-3.2.113.tgz#b7f6d11ad00e787558924158164adab2a7386502"
integrity sha512-yNq5+bZFzNuygzC0nTbJ9cfktMTF7EwUerHWHSc+2sxJELhA5C2j/Ucu+fHmKIr+3TF6j2JCJiK/mO0SoRkdSQ==

constructs@^3.2.80:
version "3.3.263"
resolved "https://registry.yarnpkg.com/constructs/-/constructs-3.3.263.tgz#d1c0391155d28e34534d2ab4266199f260258ba6"
integrity sha512-PZFnpaTjn7lHSk1+D4B6/pu1M0l+IRHt/lMIk2kkUMgsuhCSu2iFEh0uSw/PsDO4oZ1WaT9FZpvOoRJpC5jcJA==
version "3.4.39"
resolved "https://registry.yarnpkg.com/constructs/-/constructs-3.4.39.tgz#607085f072221b8c6e80226021cca38d3dba0355"
integrity sha512-tj2m8GUD155rwQXmfHMZvMtBwexTEU4m7rxVkNWSShl1bkhyYV8gVi8hrrG8MtSiizkz4FheYPlkU+O3YIEo/w==

emoji-regex@^8.0.0:
version "8.0.0"
Expand All @@ -109,69 +104,64 @@ get-caller-file@^2.0.5:
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==

graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.4"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
version "4.2.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==

is-fullwidth-code-point@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==

js-yaml@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f"
integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
argparse "^2.0.1"

jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==
optionalDependencies:
graceful-fs "^4.1.6"

require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==

sscaff@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/sscaff/-/sscaff-1.2.0.tgz#d015f199ac53c2df66c4b6135b29bd01f7885445"
integrity sha512-Xyf2tWLnO0Z297FKag0e8IXFIpnYRWZ3FBn4dN2qlMRsOcpf0P54FPhvdcb1Es0Fm4hbhYYXa23jR+VPGPQhSg==
version "1.2.274"
resolved "https://registry.yarnpkg.com/sscaff/-/sscaff-1.2.274.tgz#3ae52042fbeb244b01b89542a56ce5b247284be9"
integrity sha512-sztRa50SL1LVxZnF1au6QT1SC2z0S1oEOyi2Kpnlg6urDns93aL32YxiJcNkLcY+VHFtVqm/SRv4cb+6LeoBQA==

string-width@^4.1.0, string-width@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5"
integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.0"
strip-ansi "^6.0.1"

strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.0"

ts-dedent@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.0.0.tgz#47c5eb23d9096f3237cc413bc82d387d36dbe690"
integrity sha512-DfxKjSFQfw9+uf7N9Cy8Ebx9fv5fquK4hZ6SD3Rzr+1jKP6AVA6H8+B5457ZpUs0JKsGpGqIevbpZ9DMQJDp1A==
ansi-regex "^5.0.1"

ts-dedent@^2.2.0:
ts-dedent@^2.0.0, ts-dedent@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5"
integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==

typescript@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==

universalify@^0.1.0:
version "0.1.2"
Expand All @@ -188,19 +178,19 @@ wrap-ansi@^7.0.0:
strip-ansi "^6.0.0"

y18n@^5.0.5:
version "5.0.5"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.5.tgz#8769ec08d03b1ea2df2500acef561743bbb9ab18"
integrity sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==
version "5.0.8"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==

yaml@^1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==
version "1.10.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==

yargs-parser@^20.2.2:
version "20.2.4"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==
version "20.2.9"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==

yargs@^16.2.0:
version "16.2.0"
Expand Down
73 changes: 70 additions & 3 deletions .github/workflows/cdkactions_build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
with:
context: .
file: ./Dockerfile
push: ${{ github.ref == 'refs/heads/master' }}
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/feat/') == true }}
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/website:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/website:latest,pennlabs/website:${{ github.sha }}
Expand All @@ -69,22 +69,24 @@ jobs:
cd k8s
yarn install --frozen-lockfile

# get repo name (by removing owner/organization)
# Get repo name (by removing owner/organization)
export RELEASE_NAME=${REPOSITORY#*/}

# Export RELEASE_NAME as an output
echo "::set-output name=RELEASE_NAME::$RELEASE_NAME"

yarn build
env:
PR_NUMBER: ${{ steps.pr.outputs.pull_request_number }}
GIT_SHA: ${{ github.sha }}
REPOSITORY: ${{ github.repository }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
- name: Deploy
if: steps.synth.outcome == 'success'
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
# Get repo name from synth step
RELEASE_NAME=${{ steps.synth.outputs.RELEASE_NAME }}

# Deploy
Expand All @@ -96,3 +98,68 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}
needs:
- publish-frontend
feature-branch-deploy:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/feat/') == true
steps:
- uses: actions/checkout@v2
- name: Get Pull Request Metadata
id: pr
run: |-
echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")"
echo "::set-output name=pull_request_closed::$(gh pr view --json closed -q .closed || echo "")"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: synth
name: Synth cdk8s manifests
if: (steps.pr.outputs.pull_request_number) && (steps.pr.outputs.pull_request_closed == 'false')
run: |-
cd k8s
yarn install --frozen-lockfile

# Get repo name (by removing owner/organization)
export DEPLOY_TO_FEATURE_BRANCH=true
export RELEASE_NAME=${REPOSITORY#*/}-pr-${{ steps.pr.outputs.pull_request_number }}

# Export RELEASE_NAME as an output
echo "::set-output name=RELEASE_NAME::$RELEASE_NAME"

yarn build
env:
PR_NUMBER: ${{ steps.pr.outputs.pull_request_number }}
GIT_SHA: ${{ github.sha }}
REPOSITORY: ${{ github.repository }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
- name: Deploy
if: steps.synth.outcome == 'success'
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
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: Find announcement if exists
uses: peter-evans/find-comment@v2
id: find-announcement
with:
issue-number: ${{ steps.pr.outputs.pull_request_number }}
body-includes: Deployment preview for
token: ${{ secrets.GITHUB_TOKEN }}
- name: Announce successful feature branch deployment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.find-announcement.outputs.comment-id }}
issue-number: ${{ steps.pr.outputs.pull_request_number }}
edit-mode: replace
body: |-
Deployment preview for commit `${{ github.sha }}` ready at:
[pr-${{ steps.pr.outputs.pull_request_number }}.pennlabs.org](https://pr-${{ steps.pr.outputs.pull_request_number }}.pennlabs.org)
needs:
- publish-frontend
Loading