Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Nov 8, 2023
1 parent 0f7352c commit fb3a8fc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions opt/adler/moodle/adler_setup/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
*/
function get_updated_release_info(string $github_repo, string $version, string $old_version = null) {
$url = "https://api.github.com/repos/" . $github_repo . "/releases";
cli_writeln("Fetching release info from $url");

$context = stream_context_create(['http' => ['user_agent' => 'PHP']]);
$response = file_get_contents($url, false, $context);
// $response = "[{\"url\":\"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\"assets_url\":\"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\"upload_url\":\"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\"html_url\":\"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\"id\":108886375,\"author\":{\"login\":\"Glutamat42\",\"id\":51326311,\"node_id\":\"MDQ6VXNlcjUxMzI2MzEx\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/51326311?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/Glutamat42\",\"html_url\":\"https://github.com/Glutamat42\",\"followers_url\":\"https://api.github.com/users/Glutamat42/followers\",\"following_url\":\"https://api.github.com/users/Glutamat42/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/Glutamat42/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/Glutamat42/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/Glutamat42/subscriptions\",\"organizations_url\":\"https://api.github.com/users/Glutamat42/orgs\",\"repos_url\":\"https://api.github.com/users/Glutamat42/repos\",\"events_url\":\"https://api.github.com/users/Glutamat42/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/Glutamat42/received_events\",\"type\":\"User\",\"site_admin\":false},\"node_id\":\"RE_kwDOIidAYc4GfXln\",\"tag_name\":\"1.0.0\",\"target_commitish\":\"main\",\"name\":\"v1.0.0\",\"draft\":false,\"prerelease\":false,\"created_at\":\"2023-06-16T14:30:58Z\",\"published_at\":\"2023-06-16T14:50:20Z\",\"assets\":[],\"tarball_url\":\"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\"zipball_url\":\"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\",\"body\":\"This initial release of the project supports both Moodle 4.2 and Moodle 4.1 (LTS) versions. It introduces essential functionality to enhance the project's capabilities. Key highlights of this release include:\\r\\n\\r\\n- Compatibility with Moodle 4.2 and Moodle 4.1 (LTS)\\r\\n- API endpoints for integration with external systems (backend)\\r\\n- Backup and restore functionality\\r\\n- Plugin interface for clear communication functions between plugins (availability_adler)\\r\\n- Documentation\"}]";
// $response = "[\n {\n \"url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\n \"assets_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\n \"upload_url\": \"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\n \"html_url\": \"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\n \"id\": 108886375,\n \"node_id\": \"RE_kwDOIidAYc4GfXln\",\n \"tag_name\": \"1.0.0\",\n \"target_commitish\": \"main\",\n \"name\": \"v1.0.0\",\n \"draft\": false,\n \"prerelease\": false,\n \"created_at\": \"2023-06-16T14:30:58Z\",\n \"published_at\": \"2023-06-16T14:50:20Z\",\n \"assets\": [],\n \"tarball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\n \"zipball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\"\n },\n {\n \"url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\n \"assets_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\n \"upload_url\": \"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\n \"html_url\": \"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\n \"id\": 108886375,\n \"node_id\": \"RE_kwDOIidAYc4GfXln\",\n \"tag_name\": \"1.0.3\",\n \"target_commitish\": \"main\",\n \"name\": \"v1.0.3\",\n \"draft\": false,\n \"prerelease\": false,\n \"created_at\": \"2023-06-16T14:30:58Z\",\n \"published_at\": \"2023-06-16T14:50:20Z\",\n \"assets\": [],\n \"tarball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\n \"zipball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\"\n },\n {\n \"url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\n \"assets_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\n \"upload_url\": \"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\n \"html_url\": \"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\n \"id\": 108886375,\n \"node_id\": \"RE_kwDOIidAYc4GfXln\",\n \"tag_name\": \"2.0.0\",\n \"target_commitish\": \"main\",\n \"name\": \"v2.0.0\",\n \"draft\": false,\n \"prerelease\": false,\n \"created_at\": \"2023-06-16T14:30:58Z\",\n \"published_at\": \"2023-06-16T14:50:20Z\",\n \"assets\": [],\n \"tarball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\n \"zipball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\"\n },\n {\n \"url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\n \"assets_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\n \"upload_url\": \"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\n \"html_url\": \"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\n \"id\": 108886375,\n \"node_id\": \"RE_kwDOIidAYc4GfXln\",\n \"tag_name\": \"2.0.1\",\n \"target_commitish\": \"main\",\n \"name\": \"v2.0.1\",\n \"draft\": false,\n \"prerelease\": false,\n \"created_at\": \"2023-06-16T14:30:58Z\",\n \"published_at\": \"2023-06-16T14:50:20Z\",\n \"assets\": [],\n \"tarball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\n \"zipball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\"\n },\n {\n \"url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\n \"assets_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\n \"upload_url\": \"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\n \"html_url\": \"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\n \"id\": 108886375,\n \"node_id\": \"RE_kwDOIidAYc4GfXln\",\n \"tag_name\": \"2.1.0\",\n \"target_commitish\": \"main\",\n \"name\": \"v2.1.0\",\n \"draft\": false,\n \"prerelease\": false,\n \"created_at\": \"2023-06-16T14:30:58Z\",\n \"published_at\": \"2023-06-16T14:50:20Z\",\n \"assets\": [],\n \"tarball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\n \"zipball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\"\n },\n {\n \"url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375\",\n \"assets_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets\",\n \"upload_url\": \"https://uploads.github.com/repos/ProjektAdLer/MoodlePluginLocal/releases/108886375/assets{?name,label}\",\n \"html_url\": \"https://github.com/ProjektAdLer/MoodlePluginLocal/releases/tag/1.0.0\",\n \"id\": 108886375,\n \"node_id\": \"RE_kwDOIidAYc4GfXln\",\n \"tag_name\": \"3.0.0\",\n \"target_commitish\": \"main\",\n \"name\": \"v3.0.0\",\n \"draft\": false,\n \"prerelease\": false,\n \"created_at\": \"2023-06-16T14:30:58Z\",\n \"published_at\": \"2023-06-16T14:50:20Z\",\n \"assets\": [],\n \"tarball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/tarball/1.0.0\",\n \"zipball_url\": \"https://api.github.com/repos/ProjektAdLer/MoodlePluginLocal/zipball/1.0.0\"\n }\n]";
cli_writeln("Response: $response");

$releases = json_decode($response, true);
$matchingReleases = array_filter($releases, function ($release) use ($version) {
Expand Down

0 comments on commit fb3a8fc

Please sign in to comment.