Skip to content

Commit 885d994

Browse files
use hash, not pr number
1 parent eab5b30 commit 885d994

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

.github/pycafe-create-status.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111

1212
repo_name = "widgetti/ipyreact"
13-
pr_number = int(sys.argv[1]) # e.g 65
14-
run_id = sys.argv[2] # e.g 1324, usually obtained via ${{ github.run_id }} in GitHub Actions workflow files
13+
commit_sha = sys.argv[1] # e.g d39677a321bca34df41ecc87ff7e539b450207f2
14+
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
1515
type = "solara" # streamlit/dash/vizro/solara/panel
1616

1717
# your default code
@@ -40,13 +40,10 @@ class ConfettiWidget(ipyreact.ValueWidget):
4040

4141
# GitHub Python API
4242
repo = g.get_repo(repo_name)
43-
pr = repo.get_pull(pr_number)
4443

4544
base_url = f"https://py.cafe/snippet/{type}/v1"
4645
url = f"{base_url}#code={quote(code)}&requirements={quote(requirements)}"
4746

48-
commit_sha = pr.head.sha
49-
5047
# Define the deployment status
5148
state = "success" # Options: 'error', 'failure', 'pending', 'success'
5249
description = "Test out this PR on a PyCafe environment"
@@ -55,4 +52,4 @@ class ConfettiWidget(ipyreact.ValueWidget):
5552
# Create the status on the commit
5653
commit = repo.get_commit(commit_sha)
5754
commit.create_status(state="success", target_url=url, description="Test this PR in PyCafe environment", context="PyCafe")
58-
print(f"Deployment status added to commit {commit_sha}, PR https://github.com/{repo_name}/pull/{pr_number}")
55+
print(f"Deployment status added to commit {commit_sha}")

.github/workflows/pycafe.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
- name: Create PyCafe status link
1616
run: |
1717
pip install PyGithub
18-
python .github/pycafe-create-status.py ${{ github.event.workflow_run.pull_requests[0].number }} ${{ github.event.workflow_run.id }}
18+
python .github/pycafe-create-status.py ${{ github.event.workflow_run.head_sha }} ${{ github.event.workflow_run.id }}
1919
env:
2020
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)