-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0b98fc
commit 9e4c064
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
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,55 @@ | ||
import os | ||
import sys | ||
from urllib.parse import quote | ||
|
||
from github import Github | ||
|
||
# Authenticate with GitHub | ||
access_token = os.getenv("GITHUB_TOKEN") | ||
g = Github(access_token) | ||
|
||
|
||
repo_name = "widgetti/solara" | ||
pr_number = int(sys.argv[1]) # e.g 65 | ||
type = "solara" # streamlit/dash/vizro/solara/panel | ||
|
||
# your default code | ||
code = """import ipyreact | ||
class ConfettiWidget(ipyreact.ValueWidget): | ||
_esm = \""" | ||
import confetti from "canvas-confetti"; | ||
import * as React from "react"; | ||
export default function({value, setValue}) { | ||
return <button onClick={() => confetti() && setValue(value + 1)}> | ||
{value || 0} times confetti | ||
</button> | ||
};\""" | ||
page = ConfettiWidget() | ||
""" | ||
|
||
# your default requirements | ||
requirements = """solara | ||
ipyreact | ||
""" | ||
|
||
# GitHub Python API | ||
repo = g.get_repo(repo_name) | ||
pr = repo.get_pull(pr_number) | ||
|
||
base_url = f"https://py.cafe/snippet/{type}/v1" | ||
url = f"{base_url}#code={quote(code)}&requirements={quote(requirements)}" | ||
|
||
commit_sha = pr.head.sha | ||
|
||
# Define the deployment status | ||
state = "success" # Options: 'error', 'failure', 'pending', 'success' | ||
description = "Test out this PR on a PyCafe environment" | ||
context = "PyCafe" | ||
|
||
# Create the status on the commit | ||
commit = repo.get_commit(commit_sha) | ||
commit.create_status(state="success", target_url=url, description="Test this PR in PyCafe environment", context="PyCafe") | ||
print(f"Deployment status added to commit {commit_sha}, PR https://github.com/{repo_name}/pull/{pr_number}") |
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,17 @@ | ||
--- | ||
name: PyCafe Sandbox Link | ||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- synchronize | ||
jobs: | ||
create-status-link: null | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Create PyCafe status link | ||
run: python .github/pycafe-create-status.py ${{ github.event.number }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |