@@ -161,12 +161,22 @@ func (c *InstallConfig) Install() (string, error) {
161
161
162
162
} else {
163
163
// Attempt to verify by artifact attestations.
164
- // If there are no attestations, it will be ignored without errors.
164
+ repo , err := c .fetchRepository ()
165
+ if err != nil {
166
+ return "" , fmt .Errorf ("Failed to get GitHub repository metadata: %s" , err )
167
+ }
168
+ // If the repository is private, artifact attestations is not always available
169
+ // because it requires GitHub Enterprise Cloud plan, so we skip verification here.
170
+ if repo .Private != nil && * repo .Private {
171
+ skipVerify = true
172
+ }
173
+
165
174
log .Printf ("[DEBUG] Download artifact attestations" )
166
175
attestations , err := c .fetchArtifactAttestations (checksumsFile )
167
176
if err != nil {
168
177
var gerr * github.ErrorResponse
169
- // If experimental mode is enabled, enforces that attestations are present.
178
+ // If there are no attestations, it will be ignored without errors.
179
+ // However, experimental mode is enabled, enforces that attestations are present.
170
180
if errors .As (err , & gerr ) && gerr .Response .StatusCode == 404 && ! IsExperimentalModeEnabled () {
171
181
log .Printf ("[DEBUG] Artifact attestations not found and will be ignored: %s" , err )
172
182
skipVerify = true
@@ -239,6 +249,18 @@ func (c *InstallConfig) fetchReleaseAssets() (map[string]*github.ReleaseAsset, e
239
249
return assets , nil
240
250
}
241
251
252
+ // fetchRepository fetches GitHub repository metadata.
253
+ func (c * InstallConfig ) fetchRepository () (* github.Repository , error ) {
254
+ ctx := context .Background ()
255
+ client , err := newGitHubClient (ctx , c )
256
+ if err != nil {
257
+ return nil , err
258
+ }
259
+
260
+ repo , _ , err := client .Repositories .Get (ctx , c .SourceOwner , c .SourceRepo )
261
+ return repo , err
262
+ }
263
+
242
264
// fetchArtifactAttestations fetches GitHub Artifact Attestations based on the given io.ReadSeeker.
243
265
func (c * InstallConfig ) fetchArtifactAttestations (artifact io.ReadSeeker ) ([]* github.Attestation , error ) {
244
266
bytes , err := io .ReadAll (artifact )
0 commit comments