From 885d99413823fbb6a7181006b80145a843cc72be Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Thu, 24 Oct 2024 13:21:34 +0200 Subject: [PATCH] use hash, not pr number --- .github/pycafe-create-status.py | 9 +++------ .github/workflows/pycafe.yml | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/pycafe-create-status.py b/.github/pycafe-create-status.py index 874e00c..acb911d 100644 --- a/.github/pycafe-create-status.py +++ b/.github/pycafe-create-status.py @@ -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 @@ -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" @@ -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}") diff --git a/.github/workflows/pycafe.yml b/.github/workflows/pycafe.yml index d44b037..7b87261 100644 --- a/.github/workflows/pycafe.yml +++ b/.github/workflows/pycafe.yml @@ -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 }}