Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an add to GitHub button on an encalve (#2256)
First frontend PR, please review properly Note that the instance id and api key should fill up when in cloud!
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...ave-manager/web/packages/app/src/emui/enclaves/components/modals/AddGithubActionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
} from "@chakra-ui/react"; | ||
import { FileDisplay } from "kurtosis-ui-components"; | ||
import { apiKey, instanceUUID } from "../../../../cookies"; | ||
|
||
export type AddGithubActionModalProps = { | ||
packageId: string; | ||
isOpen: boolean; | ||
onClose: () => void; | ||
}; | ||
|
||
export const AddGithubActionModal = ({ isOpen, onClose, packageId }: AddGithubActionModalProps) => { | ||
const commands = ` | ||
name: CI | ||
on: | ||
pull_request: | ||
jobs: | ||
run_kurtosis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Run Kurtosis | ||
uses: kurtosis-tech/kurtosis-github-action@v1 | ||
with: | ||
path: ${packageId} | ||
cloud_instance_id: ${instanceUUID} | ||
cloud_api_key: ${apiKey} # We recommend placing this in repository secrets;`; | ||
return ( | ||
<Modal closeOnOverlayClick={false} isOpen={isOpen} onClose={onClose} isCentered> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>Run this enclave from GitHub</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody> | ||
<FileDisplay value={commands} title={"GitHub Action YAML"} filename={"per-pr.yml"} /> | ||
</ModalBody> | ||
<ModalFooter>The GitHub Action allows you to run this package directly in CI</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; |
54 changes: 54 additions & 0 deletions
54
...e-manager/web/packages/app/src/emui/enclaves/components/widgets/AddGithubActionButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Button, ButtonProps, Tooltip } from "@chakra-ui/react"; | ||
import { isDefined } from "kurtosis-ui-components"; | ||
import { useState } from "react"; | ||
import { FiGithub } from "react-icons/fi"; | ||
import { EnclaveFullInfo } from "../../types"; | ||
import { AddGithubActionModal } from "../modals/AddGithubActionModal"; | ||
|
||
type AddGithubActionButtonProps = ButtonProps & { | ||
enclave: EnclaveFullInfo; | ||
}; | ||
|
||
export const AddGithubActionButton = ({ enclave, ...buttonProps }: AddGithubActionButtonProps) => { | ||
const [showModal, setShowModal] = useState(false); | ||
|
||
if (!isDefined(enclave.starlarkRun)) { | ||
return ( | ||
<Button isLoading={true} colorScheme={"yellow"} leftIcon={<FiGithub />} size={"sm"} {...buttonProps}> | ||
Add GitHub Action | ||
</Button> | ||
); | ||
} | ||
|
||
if (enclave.starlarkRun.isErr) { | ||
return ( | ||
<Tooltip label={"An error occurred while starting the enclave"}> | ||
<Button isDisabled={true} colorScheme={"yellow"} leftIcon={<FiGithub />} size={"sm"} {...buttonProps}> | ||
Add GitHub Action | ||
</Button> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<Tooltip label={`Steps to run this package from CI`} openDelay={1000}> | ||
<Button | ||
colorScheme={"yellow"} | ||
leftIcon={<FiGithub />} | ||
onClick={() => setShowModal(true)} | ||
size={"sm"} | ||
variant={"solid"} | ||
{...buttonProps} | ||
> | ||
Add GitHub Action | ||
</Button> | ||
</Tooltip> | ||
<AddGithubActionModal | ||
packageId={enclave.starlarkRun.value.packageId} | ||
isOpen={showModal} | ||
onClose={() => setShowModal(false)} | ||
/> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters