App does not update after new GitHub push, again

I’m having the same issue as: App does not update after new GitHub push

I tried all suggested solutions: rebooting, removing the app and redeploying, and reseting the github connection.
None worked, pushing new commits to the github repo does not refresh the app.
I am sure it’s the same branch. In fact the same app was working fine and I did not touch it for a long time, but suddenly stopped refreshing on new commits

I’m having the same issue , I think it is something related to the watcher and it is a general issue not related to a specific app or repo. hope this be solved soon.

I had to temporarily rename my app and redeploy.

Apparently this issue was fixed, I did not change anything on the app but it started refreshing on new commits as it was before.
I’m thankful for the fix, although communication from the team would’ve been appreciated.

I had to come up with this whole workarround below while waiting:

def trigger_git_pull():
    """Pull using HTTPS with GitHub PAT from secrets.
    Returns True if successful or skipped."""
    try:
        # Get PAT from Streamlit secrets
        github_token = st.secrets.get("GITHUB_TOKEN", None)

        if not github_token:
            st.error(
                "⚠️ No GITHUB_TOKEN found in secrets. "
                "Add it in Streamlit Cloud settings to enable auto-updates."
            )
            return None

        repo_dir = Path.cwd()

        # Get current repo info
        result = subprocess.run(
            ["git", "config", "--get", "remote.origin.url"],
            cwd=repo_dir,
            capture_output=True,
            text=True,
        )

        if result.returncode != 0:
            st.error("Failed to get repository URL")
            return None

        original_url = result.stdout.strip()

        # Extract repo path from various URL formats
        if original_url.startswith("git@github.com:"):
            # SSH format: git@github.com:user/repo.git
            repo_path = original_url.replace("git@github.com:", "").replace(".git", "")
        elif "github.com/" in original_url:
            # HTTPS format (with or without token): 
            # https://[token@]github.com/user/repo.git
            repo_path = original_url.split("github.com/", 1)[1].replace(".git", "")
        else:
            st.error(f"Unsupported URL format: {original_url}")
            return None

        # Build HTTPS URL with token
        https_url = f"https://{github_token}@github.com/{repo_path}.git"

        try:
            # Temporarily set remote URL with token
            subprocess.run(
                ["git", "remote", "set-url", "origin", https_url],
                cwd=repo_dir,
                check=True,
                capture_output=True,
            )

            # Pull changes
            result = subprocess.run(
                ["git", "pull", "origin"],
                cwd=repo_dir,
                capture_output=True,
                text=True,
                timeout=120,
            )
        finally:
            # Always restore original URL, even if pull fails
            subprocess.run(
                ["git", "remote", "set-url", "origin", original_url],
                cwd=repo_dir,
                capture_output=True,
            )

        if result.returncode == 0:
            # Check if there were actual updates
            if "Already up to date" not in result.stdout:
                # Clear all caches and rerun to load new data
                st.cache_data.clear()
                st.cache_resource.clear()
                st.toast("✅ New data loaded successfully")
                st.rerun()
        else:
            st.error(f"Git pull failed: {repr(result)}")

    except subprocess.TimeoutExpired:
        st.error("subprocess command took too long")
    except subprocess.CalledProcessError as e:
        st.error(f"Git command failed: {e.stderr}")
    except Exception as e:
        st.error(f"Error: {repr(e)}")

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.