Skip to content

Commit

Permalink
use hash, not pr number
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Oct 24, 2024
1 parent eab5b30 commit 885d994
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions .github/pycafe-create-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


repo_name = "widgetti/ipyreact"
pr_number = int(sys.argv[1]) # e.g 65
run_id = sys.argv[2] # e.g 1324, usually obtained via ${{ github.run_id }} in GitHub Actions workflow files
commit_sha = sys.argv[1] # e.g d39677a321bca34df41ecc87ff7e539b450207f2
run_id = sys.argv[2] # e.g 1324, usually obtained via ${{ github.run_id }} or ${{ github.event.workflow_run.id }} in GitHub Actions workflow files
type = "solara" # streamlit/dash/vizro/solara/panel

# your default code
Expand Down Expand Up @@ -40,13 +40,10 @@ class ConfettiWidget(ipyreact.ValueWidget):

# 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"
Expand All @@ -55,4 +52,4 @@ class ConfettiWidget(ipyreact.ValueWidget):
# 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}")
print(f"Deployment status added to commit {commit_sha}")
2 changes: 1 addition & 1 deletion .github/workflows/pycafe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
- name: Create PyCafe status link
run: |
pip install PyGithub
python .github/pycafe-create-status.py ${{ github.event.workflow_run.pull_requests[0].number }} ${{ github.event.workflow_run.id }}
python .github/pycafe-create-status.py ${{ github.event.workflow_run.head_sha }} ${{ github.event.workflow_run.id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 885d994

Please sign in to comment.