Skip to content

Commit

Permalink
Merge pull request #1660 from garridobarrera/main
Browse files Browse the repository at this point in the history
New method to retrieve repo action variable
  • Loading branch information
bitwiseman authored May 23, 2023
2 parents 725d1c6 + 14e609d commit acf1dde
Show file tree
Hide file tree
Showing 10 changed files with 503 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,21 @@ public GHContent getReadme() throws IOException {
return requester.withUrlPath(getApiTailUrl("readme")).fetch(GHContent.class).wrap(this);
}

/**
* Gets a variable by name
*
* @param name
* the variable name (e.g. test-variable)
* @return the variable
* @throws IOException
* the io exception
*/
public GHRepositoryVariable getRepoVariable(String name) throws IOException {
return root().createRequest()
.withUrlPath(getApiTailUrl("actions/variables"), name)
.fetch(GHRepositoryVariable.class);
}

/**
* Creates a new content, or update an existing content.
*
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepositoryVariable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.kohsuke.github;

/**
* The type Gh repository variable.
*
* @author garridobarrera
*/
public class GHRepositoryVariable {
private String name;
private String value;
private String createdAt;
private String updatedAt;

/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}

/**
* Gets value.
*
* @return the value
*/
public String getValue() {
return value;
}
}
13 changes: 13 additions & 0 deletions src/test/java/org/kohsuke/github/GHRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1581,4 +1581,17 @@ public void starTest() throws Exception {
repository.unstar();
assertThat(repository.listStargazers().toList().size(), is(0));
}

/**
* Test to check getRepoVariable method.
*
* @throws Exception
* the exception
*/
@Test
public void testRepoActionVariable() throws Exception {
GHRepository repository = getRepository();
GHRepositoryVariable variable = repository.getRepoVariable("myvar");
assertThat(variable.getValue(), is("this is my var value"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"login": "hub4j-test-org",
"id": 59470614,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU5NDcwNjE0",
"url": "https://api.github.com/orgs/hub4j-test-org",
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/59470614?v=4",
"description": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 1,
"public_gists": 0,
"followers": 8,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2020-01-03T09:09:41Z",
"updated_at": "2023-05-15T08:11:52Z",
"type": "Organization",
"total_private_repos": 1534,
"owned_private_repos": 1574,
"private_gists": 0,
"disk_usage": 4263895,
"collaborators": 72,
"billing_email": "[email protected]",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"members_allowed_repository_creation_type": "none",
"members_can_create_public_repositories": false,
"members_can_create_private_repositories": false,
"members_can_create_internal_repositories": false,
"members_can_create_pages": true,
"members_can_fork_private_repositories": false,
"web_commit_signoff_required": false,
"members_can_create_public_pages": true,
"members_can_create_private_pages": true,
"plan": {
"name": "enterprise",
"space": 976562499,
"private_repos": 999999,
"filled_seats": 5072,
"seats": 5664
},
"advanced_security_enabled_for_new_repositories": false,
"dependabot_alerts_enabled_for_new_repositories": false,
"dependabot_security_updates_enabled_for_new_repositories": false,
"dependency_graph_enabled_for_new_repositories": false,
"secret_scanning_enabled_for_new_repositories": false,
"secret_scanning_push_protection_enabled_for_new_repositories": false,
"secret_scanning_push_protection_custom_link_enabled": false,
"secret_scanning_push_protection_custom_link": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"id": 317839899,
"node_id": "MDEwOlJlcG9zaXRvcnkzMTc4Mzk4OTk=",
"name": "github-api",
"full_name": "hub4j-test-org/github-api",
"private": true,
"owner": {
"login": "hub4j-test-org",
"id": 59470614,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU5NDcwNjE0",
"avatar_url": "https://avatars.githubusercontent.com/u/59470614?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/hub4j-test-org/github-api",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/hub4j-test-org/github-api",
"forks_url": "https://api.github.com/repos/hub4j-test-org/github-api/forks",
"keys_url": "https://api.github.com/repos/hub4j-test-org/github-api/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/hub4j-test-org/github-api/teams",
"hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api/hooks",
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/events{/number}",
"events_url": "https://api.github.com/repos/hub4j-test-org/github-api/events",
"assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api/assignees{/user}",
"branches_url": "https://api.github.com/repos/hub4j-test-org/github-api/branches{/branch}",
"tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/tags",
"blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api/statuses/{sha}",
"languages_url": "https://api.github.com/repos/hub4j-test-org/github-api/languages",
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api/stargazers",
"contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api/contributors",
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscribers",
"subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscription",
"commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/hub4j-test-org/github-api/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/hub4j-test-org/github-api/contents/{+path}",
"compare_url": "https://api.github.com/repos/hub4j-test-org/github-api/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/hub4j-test-org/github-api/merges",
"archive_url": "https://api.github.com/repos/hub4j-test-org/github-api/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api/downloads",
"issues_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues{/number}",
"pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls{/number}",
"milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api/milestones{/number}",
"notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/hub4j-test-org/github-api/labels{/name}",
"releases_url": "https://api.github.com/repos/hub4j-test-org/github-api/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api/deployments",
"created_at": "2020-12-02T11:25:38Z",
"updated_at": "2022-06-10T11:48:11Z",
"pushed_at": "2023-05-15T10:30:23Z",
"git_url": "git://github.com/hub4j-test-org/github-api.git",
"ssh_url": "[email protected]:hub4j-test-org/github-api.git",
"clone_url": "https://github.com/hub4j-test-org/github-api.git",
"svn_url": "https://github.com/hub4j-test-org/github-api",
"homepage": null,
"size": 15775,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 358,
"license": null,
"allow_forking": false,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [],
"visibility": "private",
"forks": 0,
"open_issues": 358,
"watchers": 0,
"default_branch": "main",
"permissions": {
"admin": true,
"maintain": true,
"push": true,
"triage": true,
"pull": true
},
"temp_clone_token": "ABVSGFSHJP3EZB4Y6UK2PQLEMIMI2",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_auto_merge": false,
"delete_branch_on_merge": true,
"allow_update_branch": false,
"use_squash_pr_title_as_default": false,
"squash_merge_commit_message": "COMMIT_MESSAGES",
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"merge_commit_message": "PR_TITLE",
"merge_commit_title": "MERGE_MESSAGE",
"organization": {
"login": "hub4j-test-org",
"id": 59470614,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU5NDcwNjE0",
"avatar_url": "https://avatars.githubusercontent.com/u/59470614?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 0,
"subscribers_count": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"login": "garridobarrera",
"id": 7021334,
"node_id": "MDQ6VXNlcjcwMjEzMzQ=",
"avatar_url": "https://avatars.githubusercontent.com/u/7021334?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/garridobarrera",
"html_url": "https://github.com/garridobarrera",
"followers_url": "https://api.github.com/users/garridobarrera/followers",
"following_url": "https://api.github.com/users/garridobarrera/following{/other_user}",
"gists_url": "https://api.github.com/users/garridobarrera/gists{/gist_id}",
"starred_url": "https://api.github.com/users/garridobarrera/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/garridobarrera/subscriptions",
"organizations_url": "https://api.github.com/users/garridobarrera/orgs",
"repos_url": "https://api.github.com/users/garridobarrera/repos",
"events_url": "https://api.github.com/users/garridobarrera/events{/privacy}",
"received_events_url": "https://api.github.com/users/garridobarrera/received_events",
"type": "User",
"site_admin": false,
"name": "José Manuel Garrido Barrera",
"company": "personal",
"blog": "",
"location": null,
"email": "[email protected]",
"hireable": null,
"bio": null,
"twitter_username": null,
"public_repos": 11,
"public_gists": 0,
"followers": 3,
"following": 2,
"created_at": "2014-03-21T10:37:00Z",
"updated_at": "2023-03-13T11:32:23Z",
"private_gists": 0,
"total_private_repos": 2,
"owned_private_repos": 2,
"disk_usage": 5935,
"collaborators": 1,
"two_factor_authentication": true,
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"id": "6831ee08-d197-4e72-b2b7-9b4c97997f3a",
"name": "orgs_hub4j-test-org",
"request": {
"url": "/orgs/hub4j-test-org",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github.v3+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "orgs_hub4j-test-org-2.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 15 May 2023 11:28:33 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"210fe7604fbf3cb73c20f3bc9dd95de3c73e21a0d2951bd667321d59e920633f\"",
"Last-Modified": "Mon, 15 May 2023 08:11:52 GMT",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4804",
"X-RateLimit-Reset": "1684151924",
"X-RateLimit-Used": "196",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "F3A4:B316:162B7156:1665F336:64621760"
}
},
"uuid": "6831ee08-d197-4e72-b2b7-9b4c97997f3a",
"persistent": true,
"insertionIndex": 2
}
Loading

0 comments on commit acf1dde

Please sign in to comment.