Repository: hub4j/github-api
Pull request #1446 (2022-04-27 18:51:00)

Adding Secrets + Public Key to Repository
# Description

Hey everyone!! I added support for creating secrets for a given repository using the API. 
The relevant docs are here: https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret

It also needed the `getPublicKey` method, also added!
I've tested this with a local snapshot. and has worked in production as well. 

I'd be happy to address any changes!!

# Before submitting a PR:

- [x] Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, [CONTRIBUTING.md](CONTRIBUTING.md) for details.
- [x] Add JavaDocs and other comments as appropriate. Consider including links in comments to relevant documentation on https://docs.github.com/en/rest .  
- [x] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
- [x] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
- [x] Push your changes to a branch other than `main`. You will create your PR from that branch.

# When creating a PR: 

- [x] Fill in the "Description" above with clear summary of the changes. This includes:
  - [x] If this PR fixes one or more issues, include "Fixes #<issue number>" lines for each issue. 
  - [x] Provide links to relevant documentation on https://docs.github.com/en/rest where possible.
- [x] All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
- [x] Enable "Allow edits from maintainers".



Patch:
diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java
index 2d934c8d0..6a1c7a6d4 100644
--- a/src/main/java/org/kohsuke/github/GHRepository.java
+++ b/src/main/java/org/kohsuke/github/GHRepository.java
@@ -3184,6 +3184,20 @@ public class GHRepository extends GHObject {
                 .wrapUp(this);
     }
 
+    /**
+     * Gets the public key for the given repo
+     *
+     * @return the public key
+     * @throws IOException
+     *             the io exception
+     */
+    public GHRepositoryPublicKey getPublicKey() throws IOException {
+        return root().createRequest()
+                .withUrlPath(getApiTailUrl("/actions/secrets/public-key"))
+                .fetch(GHRepositoryPublicKey.class)
+                .wrapUp(this);
+    }
+
     // Only used within listTopics().
     private static class Topics {
         public List<String> names;
@@ -3223,6 +3237,27 @@ public class GHRepository extends GHObject {
                 .send();
     }
 
+    /**
+     * Set/Update a repository secret
+     * "https://docs.github.com/rest/reference/actions#create-or-update-a-repository-secret"
+     *
+     * @param secretName
+     *            the name of the secret
+     * @param encryptedValue
+     *            The encrypted value for this secret
+     * @param publicKeyId
+     *            The id of the Public Key used to encrypt this secret
+     * @throws IOException
+     *             the io exception
+     */
+    public void createSecret(String secretName, String encryptedValue, String publicKeyId) throws IOException {
+        root().createRequest()
+                .method("PUT")
+                .with("encrypted_value", encryptedValue)
+                .with("key_id", publicKeyId)
+                .withUrlPath(getApiTailUrl("actions/secrets") + "/" + secretName)
+                .send();
+    }
     /**
      * Create a tag. See https://developer.github.com/v3/git/tags/#create-a-tag-object
      *
diff --git a/src/main/java/org/kohsuke/github/GHRepositoryPublicKey.java b/src/main/java/org/kohsuke/github/GHRepositoryPublicKey.java
new file mode 100644
index 000000000..506987e53
--- /dev/null
+++ b/src/main/java/org/kohsuke/github/GHRepositoryPublicKey.java
@@ -0,0 +1,38 @@
+package org.kohsuke.github;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * A public key for the given repository
+ *
+ * @author Aditya Bansal
+ */
+public class GHRepositoryPublicKey extends GHObject {
+    // Not provided by the API.
+    @JsonIgnore
+    private GHRepository owner;
+
+    private String keyId;
+    private String key;
+
+    @Override
+    public URL getHtmlUrl() throws IOException {
+        return null;
+    }
+
+    public String getKeyId() {
+        return keyId;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    GHRepositoryPublicKey wrapUp(GHRepository owner) {
+        this.owner = owner;
+        return this;
+    }
+}


Test patch:
diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java
index 8b52a60d8..35021925b 100644
--- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java
+++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java
@@ -753,6 +753,15 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
         assertThat(refs[0].getRef(), equalTo("refs/heads/main"));
     }
 
+    @Test
+    public void getPublicKey() throws Exception {
+        GHRepository repo = getTempRepository();
+        GHRepositoryPublicKey publicKey = repo.getPublicKey();
+        assertThat(publicKey, notNullValue());
+        assertThat(publicKey.getKey(), equalTo("test-key"));
+        assertThat(publicKey.getKeyId(), equalTo("key-id"));
+    }
+
     @Test
     public void getRefsHeads() throws Exception {
         GHRepository repo = getTempRepository();
@@ -1099,4 +1108,9 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
         repository.dispatch("test", clientPayload);
     }
 
+    @Test
+    public void createSecret() throws Exception {
+        GHRepository repo = getTempRepository();
+        repo.createSecret("secret", "encrypted", "public");
+    }
 }
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/orgs_hub4j-test-org-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/orgs_hub4j-test-org-2.json
new file mode 100644
index 000000000..f20dcc402
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/orgs_hub4j-test-org-2.json
@@ -0,0 +1,41 @@
+{
+  "login": "hub4j-test-org",
+  "id": 7544739,
+  "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+  "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://avatars3.githubusercontent.com/u/7544739?v=4",
+  "description": null,
+  "is_verified": false,
+  "has_organization_projects": true,
+  "has_repository_projects": true,
+  "public_repos": 10,
+  "public_gists": 0,
+  "followers": 0,
+  "following": 0,
+  "html_url": "https://github.com/hub4j-test-org",
+  "created_at": "2014-05-10T19:39:11Z",
+  "updated_at": "2015-04-20T00:42:30Z",
+  "type": "Organization",
+  "total_private_repos": 0,
+  "owned_private_repos": 0,
+  "private_gists": 0,
+  "disk_usage": 147,
+  "collaborators": 0,
+  "billing_email": "kk@kohsuke.org",
+  "default_repository_permission": "none",
+  "members_can_create_repositories": false,
+  "two_factor_requirement_enabled": false,
+  "plan": {
+    "name": "free",
+    "space": 976562499,
+    "private_repos": 0,
+    "filled_seats": 11,
+    "seats": 0
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/repos_hub4j-test-org_github-api-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/repos_hub4j-test-org_github-api-3.json
new file mode 100644
index 000000000..6cc98c90e
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/repos_hub4j-test-org_github-api-3.json
@@ -0,0 +1,332 @@
+{
+  "id": 206888201,
+  "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=",
+  "name": "github-api",
+  "full_name": "hub4j-test-org/github-api",
+  "private": false,
+  "owner": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?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": "Resetting",
+  "fork": true,
+  "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": "2019-09-06T23:26:04Z",
+  "updated_at": "2019-12-20T00:07:51Z",
+  "pushed_at": "2020-01-10T23:15:59Z",
+  "git_url": "git://github.com/hub4j-test-org/github-api.git",
+  "ssh_url": "git@github.com: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": "http://github-api.kohsuke.org/",
+  "size": 11413,
+  "stargazers_count": 0,
+  "watchers_count": 0,
+  "language": "Java",
+  "has_issues": true,
+  "has_projects": true,
+  "has_downloads": true,
+  "has_wiki": true,
+  "has_pages": false,
+  "forks_count": 0,
+  "mirror_url": null,
+  "archived": false,
+  "disabled": false,
+  "open_issues_count": 0,
+  "license": {
+    "key": "mit",
+    "name": "MIT License",
+    "spdx_id": "MIT",
+    "url": "https://api.github.com/licenses/mit",
+    "node_id": "MDc6TGljZW5zZTEz"
+  },
+  "forks": 0,
+  "open_issues": 0,
+  "watchers": 0,
+  "default_branch": "main",
+  "permissions": {
+    "admin": true,
+    "push": true,
+    "pull": true
+  },
+  "temp_clone_token": "",
+  "allow_squash_merge": true,
+  "allow_merge_commit": true,
+  "allow_rebase_merge": true,
+  "delete_branch_on_merge": false,
+  "organization": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?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
+  },
+  "parent": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": false,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2020-01-10T19:14:02Z",
+    "pushed_at": "2020-01-10T19:14:21Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 17575,
+    "stargazers_count": 602,
+    "watchers_count": 602,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 444,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 55,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 444,
+    "open_issues": 55,
+    "watchers": 602,
+    "default_branch": "main"
+  },
+  "source": {
+    "id": 617210,
+    "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
+    "name": "github-api",
+    "full_name": "hub4j/github-api",
+    "private": false,
+    "owner": {
+      "login": "hub4j",
+      "id": 54909825,
+      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
+      "gravatar_id": "",
+      "url": "https://api.github.com/users/hub4j",
+      "html_url": "https://github.com/hub4j",
+      "followers_url": "https://api.github.com/users/hub4j/followers",
+      "following_url": "https://api.github.com/users/hub4j/following{/other_user}",
+      "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
+      "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
+      "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
+      "organizations_url": "https://api.github.com/users/hub4j/orgs",
+      "repos_url": "https://api.github.com/users/hub4j/repos",
+      "events_url": "https://api.github.com/users/hub4j/events{/privacy}",
+      "received_events_url": "https://api.github.com/users/hub4j/received_events",
+      "type": "Organization",
+      "site_admin": false
+    },
+    "html_url": "https://github.com/hub4j/github-api",
+    "description": "Java API for GitHub",
+    "fork": false,
+    "url": "https://api.github.com/repos/hub4j/github-api",
+    "forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
+    "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
+    "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
+    "teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
+    "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
+    "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
+    "events_url": "https://api.github.com/repos/hub4j/github-api/events",
+    "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
+    "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
+    "tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
+    "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
+    "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
+    "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
+    "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
+    "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
+    "languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
+    "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
+    "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
+    "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
+    "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
+    "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
+    "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
+    "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
+    "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
+    "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
+    "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
+    "merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
+    "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
+    "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
+    "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
+    "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
+    "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
+    "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
+    "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
+    "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
+    "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
+    "created_at": "2010-04-19T04:13:03Z",
+    "updated_at": "2020-01-10T19:14:02Z",
+    "pushed_at": "2020-01-10T19:14:21Z",
+    "git_url": "git://github.com/hub4j/github-api.git",
+    "ssh_url": "git@github.com:hub4j/github-api.git",
+    "clone_url": "https://github.com/hub4j/github-api.git",
+    "svn_url": "https://github.com/hub4j/github-api",
+    "homepage": "http://github-api.kohsuke.org/",
+    "size": 17575,
+    "stargazers_count": 602,
+    "watchers_count": 602,
+    "language": "Java",
+    "has_issues": true,
+    "has_projects": true,
+    "has_downloads": true,
+    "has_wiki": true,
+    "has_pages": true,
+    "forks_count": 444,
+    "mirror_url": null,
+    "archived": false,
+    "disabled": false,
+    "open_issues_count": 55,
+    "license": {
+      "key": "mit",
+      "name": "MIT License",
+      "spdx_id": "MIT",
+      "url": "https://api.github.com/licenses/mit",
+      "node_id": "MDc6TGljZW5zZTEz"
+    },
+    "forks": 444,
+    "open_issues": 55,
+    "watchers": 602,
+    "default_branch": "main"
+  },
+  "network_count": 444,
+  "subscribers_count": 0
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/repos_hub4j-test-org_github-secrets-4.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/repos_hub4j-test-org_github-secrets-4.json
new file mode 100644
index 000000000..0e0dcd235
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/__files/repos_hub4j-test-org_github-secrets-4.json
@@ -0,0 +1,3 @@
+{
+
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/orgs_hub4j-test-org-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/orgs_hub4j-test-org-2.json
new file mode 100644
index 000000000..e7f3541c5
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/orgs_hub4j-test-org-2.json
@@ -0,0 +1,48 @@
+{
+  "id": "d542cf64-ac9f-4fe7-bc38-9286b63c7828",
+  "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": {
+      "Date": "Fri, 10 Jan 2020 23:17:13 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4975",
+      "X-RateLimit-Reset": "1578701497",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"baa5a9df51598a7157caf0bf0f377482\"",
+      "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
+      "X-OAuth-Scopes": "admin:org, delete_repo, gist, repo",
+      "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "BB06:1AD3:68EF1F:799228:5E1905F6"
+    }
+  },
+  "uuid": "d542cf64-ac9f-4fe7-bc38-9286b63c7828",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/repos_hub4j-test-org_github-api-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/repos_hub4j-test-org_github-api-3.json
new file mode 100644
index 000000000..5d65cf45b
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/repos_hub4j-test-org_github-api-3.json
@@ -0,0 +1,48 @@
+{
+  "id": "18a0b001-eca8-40df-bafa-9c767c9e209a",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/temp-createSecret",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "repos_hub4j-test-org_github-api-3.json",
+    "headers": {
+      "Date": "Fri, 10 Jan 2020 23:17:13 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4974",
+      "X-RateLimit-Reset": "1578701497",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"66f07f20b59c67d96b7aecf0ae184593\"",
+      "Last-Modified": "Fri, 20 Dec 2019 00:07:51 GMT",
+      "X-OAuth-Scopes": "admin:org, delete_repo, gist, repo",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "BB06:1AD3:68EF27:799263:5E1905F9"
+    }
+  },
+  "uuid": "18a0b001-eca8-40df-bafa-9c767c9e209a",
+  "persistent": true,
+  "insertionIndex": 3
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/repos_hub4j-test-org_github-secrets-4.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/repos_hub4j-test-org_github-secrets-4.json
new file mode 100644
index 000000000..3af25c6c6
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/createSecret/mappings/repos_hub4j-test-org_github-secrets-4.json
@@ -0,0 +1,54 @@
+{
+  "id": "f654b3ef-74dc-4775-8809-f07c2a44925e",
+  "name": "repos_hub4j-test-org_github-api_git_refs",
+  "request": {
+    "url": "/repos/hub4j-test-org/github-api/actions/secrets/secret",
+    "method": "PUT",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    },
+    "bodyPatterns": [
+      {
+        "equalToJson": "{\"key_id\":\"public\",\"encrypted_value\":\"encrypted\"}",
+        "ignoreArrayOrder": true,
+        "ignoreExtraElements": true
+      }
+    ]
+  },
+  "response": {
+    "status": 201,
+    "headers": {
+      "Date": "Fri, 10 Jan 2020 23:17:15 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "201 Created",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4972",
+      "X-RateLimit-Reset": "1578701497",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "\"c369f800ca461fa9cff882ed5e49b2b2\"",
+      "X-OAuth-Scopes": "admin:org, delete_repo, gist, repo",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "Location": "https://api.github.com/repos/hub4j-test-org/github-api/actions/secrets/secret",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "BB06:1AD3:68EF3B:79927A:5E1905FA"
+    }
+  },
+  "uuid": "f654b3ef-74dc-4775-8809-f07c2a44925e",
+  "persistent": true,
+  "insertionIndex": 5
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/orgs_hub4j-test-org-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/orgs_hub4j-test-org-2.json
new file mode 100644
index 000000000..5e957496c
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/orgs_hub4j-test-org-2.json
@@ -0,0 +1,4 @@
+{
+  "key_id": "93493987-1167-42ca-9ce1-668c3697700e",
+  "key": "test-key"
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/publickey_hub4j-test-org_github-api-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/publickey_hub4j-test-org_github-api-1.json
new file mode 100644
index 000000000..8eec1b1e9
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/publickey_hub4j-test-org_github-api-1.json
@@ -0,0 +1,4 @@
+{
+  "key_id": "key-id",
+  "key": "test-key"
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/repos_hub4j-test-org_temp-getpublickey-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/repos_hub4j-test-org_temp-getpublickey-2.json
new file mode 100644
index 000000000..7fbbd2b99
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/__files/repos_hub4j-test-org_temp-getpublickey-2.json
@@ -0,0 +1,126 @@
+{
+  "id": 233131910,
+  "node_id": "MDEwOlJlcG9zaXRvcnkyMzMxMzE5MTA=",
+  "name": "temp-getPublicKey",
+  "full_name": "hub4j-test-org/temp-getPublicKey",
+  "private": false,
+  "owner": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?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/temp-getPublicKey",
+  "description": "A test repository for testing the github-api project: temp-getPublicKey",
+  "fork": false,
+  "url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey",
+  "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/forks",
+  "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/keys{/key_id}",
+  "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/collaborators{/collaborator}",
+  "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/teams",
+  "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/hooks",
+  "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/issues/events{/number}",
+  "events_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/events",
+  "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/assignees{/user}",
+  "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/branches{/branch}",
+  "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/tags",
+  "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/git/blobs{/sha}",
+  "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/git/tags{/sha}",
+  "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/git/refs{/sha}",
+  "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/git/trees{/sha}",
+  "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/statuses/{sha}",
+  "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/languages",
+  "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/stargazers",
+  "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/contributors",
+  "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/subscribers",
+  "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/subscription",
+  "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/commits{/sha}",
+  "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/git/commits{/sha}",
+  "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/comments{/number}",
+  "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/issues/comments{/number}",
+  "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/contents/{+path}",
+  "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/compare/{base}...{head}",
+  "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/merges",
+  "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/{archive_format}{/ref}",
+  "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/downloads",
+  "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/issues{/number}",
+  "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/pulls{/number}",
+  "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/milestones{/number}",
+  "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/notifications{?since,all,participating}",
+  "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/labels{/name}",
+  "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/releases{/id}",
+  "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-getPublicKey/deployments",
+  "created_at": "2020-01-10T21:17:53Z",
+  "updated_at": "2020-01-10T21:17:57Z",
+  "pushed_at": "2020-01-10T21:17:55Z",
+  "git_url": "git://github.com/hub4j-test-org/temp-getPublicKey.git",
+  "ssh_url": "git@github.com:hub4j-test-org/temp-getPublicKey.git",
+  "clone_url": "https://github.com/hub4j-test-org/temp-getPublicKey.git",
+  "svn_url": "https://github.com/hub4j-test-org/temp-getPublicKey",
+  "homepage": "http://github-api.kohsuke.org/",
+  "size": 0,
+  "stargazers_count": 0,
+  "watchers_count": 0,
+  "language": null,
+  "has_issues": true,
+  "has_projects": true,
+  "has_downloads": true,
+  "has_wiki": true,
+  "has_pages": false,
+  "forks_count": 0,
+  "mirror_url": null,
+  "archived": false,
+  "disabled": false,
+  "open_issues_count": 0,
+  "license": null,
+  "forks": 0,
+  "open_issues": 0,
+  "watchers": 0,
+  "default_branch": "main",
+  "permissions": {
+    "admin": true,
+    "push": true,
+    "pull": true
+  },
+  "temp_clone_token": "",
+  "allow_squash_merge": true,
+  "allow_merge_commit": true,
+  "allow_rebase_merge": true,
+  "delete_branch_on_merge": false,
+  "organization": {
+    "login": "hub4j-test-org",
+    "id": 7544739,
+    "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
+    "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?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": 6
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/orgs_hub4j-test-org-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/orgs_hub4j-test-org-2.json
new file mode 100644
index 000000000..b6d257e69
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/orgs_hub4j-test-org-2.json
@@ -0,0 +1,47 @@
+{
+  "id": "93493987-1167-42ca-9ce1-668c3697700e",
+  "name": "orgs_hub4j-test-org",
+  "request": {
+    "url": "/orgs/hub4j-test-org",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "orgs_hub4j-test-org-2.json",
+    "headers": {
+      "Date": "Thu, 11 Jun 2020 02:20:47 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4917",
+      "X-RateLimit-Reset": "1591843209",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding, Accept, X-Requested-With",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"6bd323dd4ab2a01dae2464621246c3cd\"",
+      "Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
+      "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion",
+      "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "E5B0:5D6A:3A9A6:47E29:5EE194FE"
+    }
+  },
+  "uuid": "93493987-1167-42ca-9ce1-668c3697700e",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/publickey_hub4j-test-org_github-api-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/publickey_hub4j-test-org_github-api-1.json
new file mode 100644
index 000000000..639c74bad
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/publickey_hub4j-test-org_github-api-1.json
@@ -0,0 +1,47 @@
+{
+  "id": "188ff38b-cbda-4bdb-82f0-3dcd5eb20d72",
+  "name": "repos_hub4j-test-org_github-api",
+  "request": {
+    "url": "/repos/hub4j-test-org/temp-getPublicKey/actions/secrets/public-key",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "publickey_hub4j-test-org_github-api-1.json",
+    "headers": {
+      "Date": "Thu, 11 Jun 2020 02:20:47 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4916",
+      "X-RateLimit-Reset": "1591843209",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding, Accept, X-Requested-With",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"d50e09a217754b7ffeb7a6aa7219af30\"",
+      "Last-Modified": "Wed, 10 Jun 2020 23:27:59 GMT",
+      "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "E5B0:5D6A:3A9A9:47E30:5EE194FF"
+    }
+  },
+  "uuid": "188ff38b-cbda-4bdb-82f0-3dcd5eb20d72",
+  "persistent": true,
+  "insertionIndex": 3
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/repos_hub4j-test-org_temp-getpublickey-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/repos_hub4j-test-org_temp-getpublickey-2.json
new file mode 100644
index 000000000..90ac33e1d
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getPublicKey/mappings/repos_hub4j-test-org_temp-getpublickey-2.json
@@ -0,0 +1,48 @@
+{
+  "id": "7b70f17b-8996-4f3c-b51e-4e185e988ee0",
+  "name": "repos_hub4j-test-org_temp-getpublickey",
+  "request": {
+    "url": "/repos/hub4j-test-org/temp-getPublicKey",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "repos_hub4j-test-org_temp-getpublickey-2.json",
+    "headers": {
+      "Date": "Fri, 10 Jan 2020 21:17:59 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "Server": "GitHub.com",
+      "Status": "200 OK",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4968",
+      "X-RateLimit-Reset": "1578694499",
+      "Cache-Control": "private, max-age=60, s-maxage=60",
+      "Vary": [
+        "Accept, Authorization, Cookie, X-GitHub-OTP",
+        "Accept-Encoding"
+      ],
+      "ETag": "W/\"263909fd1bc03a2acdd17bc99b04e26b\"",
+      "Last-Modified": "Fri, 10 Jan 2020 21:17:57 GMT",
+      "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion",
+      "X-Accepted-OAuth-Scopes": "repo",
+      "X-GitHub-Media-Type": "unknown, github.v3",
+      "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
+      "Access-Control-Allow-Origin": "*",
+      "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
+      "X-Frame-Options": "deny",
+      "X-Content-Type-Options": "nosniff",
+      "X-XSS-Protection": "1; mode=block",
+      "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
+      "Content-Security-Policy": "default-src 'none'",
+      "X-GitHub-Request-Id": "F626:2189:D66144:FFC95F:5E18EA01"
+    }
+  },
+  "uuid": "7b70f17b-8996-4f3c-b51e-4e185e988ee0",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file