github-community-projects / github-community-projects/safe-settings

don't take fixed: installations[0]

Open
#782 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
921
Forks
226
Avg merge
18h 3m
Merged PRs (30d)
14

Description

## Problem Description

Running as GHA, with multiple apps being installed (in different orgs), but not all have the same ADMIN_REPO incl. the settings, let the app fail.

### What is actually happening

We had a scenario, where one app was installed in multiple different orgs (one enterprise account and two personal accounts). When the app is now executed as [GHA](https://github.com/github/safe-settings/blob/main-enterprise/docs/github-action.md), it is checking for its installations and [always just uses the first occurrence, when there are more than one](https://github.com/github/safe-settings/blob/9dbe6c72ba9066c86547a0a924e43287b8a5d761/index.js#L242).

### What is the expected behavior

Do NOT simply use the first installation, but instead use the one, which matches the GH_ORG environment setting.

### Error output, if available

```text
DEBUG (github): GitHub request: GET https://api.github.com/repos//.github/contents/safe-settings%2Fsettings.yml - 404
ERROR (probot): Error getting settings HttpError: Not Found
Unexpected error during full sync: TypeError: Cannot read properties of undefined (reading 'data')
```

## Context

### Are you using the hosted instance of probot/settings or running your own?

running your own as described in https://github.com/github/safe-settings/blob/main-enterprise/docs/github-action.md

### If running your own instance, are you using it with github.com or GitHub Enterprise?

on github.com

#### Version of probot/settings

2.1.16

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.