Skip to content

Commit 7764b0b

Browse files
authored
Merge branch 'main-enterprise' into pull-request-full-context
2 parents 7e99d46 + b5e2761 commit 7764b0b

21 files changed

+1492
-720
lines changed

.github/workflows/create-pre-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
username: ${{ github.actor }}
5959
password: ${{ secrets.GITHUB_TOKEN }}
6060
- name: Build Docker Image Locally
61-
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
61+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
6262
with:
6363
context: .
6464
file: ./Dockerfile
@@ -85,7 +85,7 @@ jobs:
8585
commitish: ${{ github.ref }}
8686
- name: Push Docker Image
8787
if: ${{ success() }}
88-
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
88+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
8989
with:
9090
context: .
9191
file: ./Dockerfile

.github/workflows/create-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
username: ${{ github.actor }}
3737
password: ${{ secrets.GITHUB_TOKEN }}
3838
- name: Build Docker Image Locally
39-
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
39+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
4040
with:
4141
context: .
4242
file: ./Dockerfile
@@ -59,7 +59,7 @@ jobs:
5959
bump: final
6060
- name: Push Docker Image
6161
if: ${{ success() }}
62-
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
62+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
6363
with:
6464
context: .
6565
file: ./Dockerfile

.github/workflows/deploy-k8s.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
steps:
3030
- name: Checkout repository
3131
uses: actions/checkout@v4
32-
- uses: azure/login@a65d910e8af852a8061c627c456678983e180302
32+
- uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5
3333
with:
3434
client-id: ${{ secrets.AZURE_CLIENT_ID }}
3535
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
3636
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
37-
- uses: azure/aks-set-context@feeca6405be94202afcb1c395616ff29b1811b9f
37+
- uses: azure/aks-set-context@c7eb093e5a5d47caa333f64974d5fd1cd4bf069d
3838
with:
3939
resource-group: ${{env.AZURE_RESOURCE_GROUP}}
4040
cluster-name: ${{env.AZURE_AKS_CLUSTER}}

.github/workflows/rc-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
- name: Set up Docker Buildx
7777
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2
7878
- name: Build and push Docker image
79-
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
79+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
8080
with:
8181
context: .
8282
push: true

NOTICE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
850850
- isexe, 2.0.0, ISC,
851851
- json-stringify-safe, 5.0.1, ISC,
852852
- lru-cache, 6.0.0, ISC,
853-
- minimatch, 3.0.4, ISC,
853+
- minimatch, 10.0.1, ISC,
854854
- octokit-auth-probot, 1.2.3, ISC,
855855
- once, 1.4.0, ISC,
856856
- probot, 11.0.6, ISC,

README.md

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,40 @@ The App listens to the following webhook events:
6464
If you rename a `<repo.yml>` that corresponds to a repo, safe-settings will rename the repo to the new name. This behavior will take effect whether the env variable `BLOCK_REPO_RENAME_BY_HUMAN` is set or not.
6565

6666
### Restricting `safe-settings` to specific repos
67-
`safe-settings` can be turned on only to a subset of repos by specifying them in the runtime settings file, `deployment-settings.yml`. If no file is specified, then the following repositories - `'admin', '.github', 'safe-settings'` are exempted by default.
68-
A sample of `deployment-settings` file is found [here](docs/sample-settings/sample-deployment-settings.yml).
69-
70-
To apply `safe-settings` __only__ to a specific list of repos, add them to the `restrictedRepos` section as `include` array.
7167

72-
To ignore `safe-settings` for a specific list of repos, add them to the `restrictedRepos` section as `exclude` array.
68+
To restrict which repositories `safe-settings` can manage, create a `deployment-settings.yml` file. This file controls the app's scope through the `restrictedRepos` configuration:
69+
70+
```yml
71+
# Using include/exclude
72+
restrictedRepos:
73+
include:
74+
- api
75+
- core-* # Matches `core-api`, `core-service`, etc.
76+
exclude:
77+
- admin
78+
- .github
79+
- safe-settings
80+
- test-* # Matches `test-repo`, etc.
81+
82+
# Or using simple array syntax for includes
83+
restrictedRepos:
84+
- admin
85+
- .github
86+
# ...
87+
```
7388

7489
> [!NOTE]
75-
> The `include` and `exclude` attributes support as well regular expressions.
76-
> By default they look for regex, Example include: ['SQL'] will look apply to repos with SQL and SQL_ and SQL- etc if you want only SQL repo then use include:['^SQL$']
90+
> Pattern matching uses glob expressions, e.g use * for wildcards.
91+
92+
When using `include` and `exclude`:
93+
94+
- If `include` is specified, will **only** run on repositories that match pattern(s)
95+
- If `exclude` is specified, will run on all repositories **except** those matching pattern(s)
96+
- If both are specified, will run only on included repositories that are'nt excluded
97+
98+
By default, if no configuration file is provided, `safe-settings` will excludes these repos: `admin`, `.github` and `safe-settings`.
99+
100+
See our [deployment-settings.yml sample](docs/sample-settings/sample-deployment-settings.yml).
77101

78102
### Custom rules
79103

@@ -329,24 +353,28 @@ The following can be configured:
329353
- `Rulesets`
330354
- `Environments` - wait timer, required reviewers, prevent self review, protected branches deployment branch policy, custom deployment branch policy, variables, deployment protection rules
331355

332-
> [!important]
333-
> It is possible to provide an `include` or `exclude` settings to restrict the `collaborators`, `teams`, `labels` to a list of repos or exclude a set of repos for a collaborator.
334-
> The include/exclude pattern can also be for glob. For e.g.:
335-
```
336-
teams:
337-
- name: Myteam-admins
338-
permission: admin
339-
- name: Myteam-developers
340-
permission: push
341-
- name: Other-team
342-
permission: push
343-
include:
344-
- '*-config'
345-
```
346-
> Will only add `Other-team` to only `*-config` repos
347-
348356
See [`docs/sample-settings/settings.yml`](docs/sample-settings/settings.yml) for a sample settings file.
349357

358+
> [!note]
359+
> When using `collaborators`, `teams` or `labels`, you can control which repositories they apply to using `include` and `exclude`:
360+
>
361+
> - If `include` is specified, settings will **only** apply to repositories that match those patterns
362+
> - If `exclude` is specified, settings will apply to all repositories **except** those matching the patterns
363+
> - If both are specified, `exclude` takes precedence over `include` but `include` patterns will still be respected
364+
>
365+
> Pattern matching uses glob expressions, e.g use * for wildcards. For example:
366+
>
367+
> ```yml
368+
> teams:
369+
> - name: Myteam-admins
370+
> permission: admin
371+
> - name: Myteam-developers
372+
> permission: push
373+
> - name: Other-team
374+
> permission: push
375+
> include:
376+
> - '*-config'
377+
> ```
350378

351379
### Additional values
352380

docs/deploy.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,42 +54,48 @@ Optional values in the .env file can be found under the [Environment variables](
5454

5555
Once you have the `.env` file configured, you are ready to start the building of the container.
5656

57-
### Docker
58-
#### Build the Docker container
57+
## Docker
58+
### Build the Docker container
5959
Once you have configured the **GitHub App** and updated the source code, you should be ready to build the container.
6060
- Change directory to inside the code base
6161
- `cd safe-settings/`
6262
- Build the container
6363
- `docker build -t safe-settings .`
6464
- This process should complete successfully and you will then have a **Docker** container ready for deployment
6565

66-
#### Run the Docker container
66+
### Run the Docker container
6767
Once the container has been successfully built, you can deploy it and start utilizing the **GitHub App**.
6868

69-
#### Start the container with docker-compose
69+
### Start the container with docker-compose
7070
If you have docker-compose installed, you can simply start and stop the **Docker** container with:
7171
- `cd safe-settings/; docker-compose --env-file .env up -d`
7272
This will start the container in the background and detached.
7373

74-
#### Start Docker container Detached in background
74+
### Start Docker container Detached in background
7575
- Start the container detached with port assigned (*Assuming port 3000 for the webhook*)
7676
- `docker run -d -p 3000:3000 safe-settings`
7777
- You should now have the container running in the background and can validate it running with the command:
7878
- `docker ps`
7979
- This should show the `safe-settings` alive and running
8080

81-
#### Start Docker container attached in forground (Debug)
81+
### Start Docker container attached in foreground (Debug)
8282
- If you need to run the container in interactive mode to validate connectivity and functionality:
8383
- `docker run -it -p 3000:3000 safe-settings`
8484
- You will now have the log of the container showing to your terminal, and can validate connectivity and functionality.
8585

86-
#### Connect to running Docker container (Debug)
86+
### Connect to running Docker container (Debug)
8787
- If you need to connect to the container thats already running, you can run the following command:
8888
- `docker exec -it safe-settings /bin/sh`
8989
- You will now be inside the running **Docker** container and can perform any troubleshooting needed
9090

91-
### Deploy the app to AWS Lambda
91+
## Deploy the app to AWS Lambda
9292
[Serverless Framework Deployment of safe-settings on AWS](AWS-README.md)
93+
94+
### Proxy Support
95+
The AWS Lambda handler, `handler.js` uses a custom `Octokit` factory that creates Octokit with ___Proxied fetch___ instead of the regular ___fetch___ when the `http_proxy`/`https_proxy` env variables are set.
96+
97+
In the future we can use the same pattern to support proxy in all deployments of the app.
98+
9399
## Deploy the app in Kubernetes
94100

95101
### __Deploying using kubectl__
@@ -205,24 +211,24 @@ Probot runs like [any other Node app](https://devcenter.heroku.com/articles/depl
205211
206212
1. Make sure you have the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) client installed.
207213
208-
1. Clone the app that you want to deploy. e.g. `git clone https://github.com/probot/stale`
214+
2. Clone the app that you want to deploy. e.g. `git clone https://github.com/probot/stale`
209215
210-
1. Create the Heroku app with the `heroku create` command:
216+
3. Create the Heroku app with the `heroku create` command:
211217
212218
$ heroku create
213219
Creating arcane-lowlands-8408... done, stack is cedar
214220
http://arcane-lowlands-8408.herokuapp.com/ | [email protected]:arcane-lowlands-8408.git
215221
Git remote heroku added
216222
217-
1. Go back to your [app settings page](https://github.com/settings/apps) and update the **Webhook URL** to the URL of your deployment, e.g. `http://arcane-lowlands-8408.herokuapp.com/`.
223+
4. Go back to your [app settings page](https://github.com/settings/apps) and update the **Webhook URL** to the "${URL_of_your_deployment}/api/github/webhooks", e.g. `http://arcane-lowlands-8408.herokuapp.com/api/github/webhooks`.
218224
219-
1. Configure the Heroku app, replacing the `APP_ID` and `WEBHOOK_SECRET` with the values for those variables, and setting the path for the `PRIVATE_KEY`:
225+
5. Configure the Heroku app, replacing the `APP_ID` and `WEBHOOK_SECRET` with the values for those variables, and setting the path for the `PRIVATE_KEY`:
220226
221227
$ heroku config:set APP_ID=aaa \
222228
WEBHOOK_SECRET=bbb \
223229
PRIVATE_KEY="$(cat ~/Downloads/*.private-key.pem)"
224230
225-
1. Deploy the app to heroku with `git push`:
231+
6. Deploy the app to heroku with `git push`:
226232
227233
$ git push heroku master
228234
...
@@ -231,12 +237,16 @@ Probot runs like [any other Node app](https://devcenter.heroku.com/articles/depl
231237
-----> Launching... done
232238
http://arcane-lowlands-8408.herokuapp.com deployed to Heroku
233239
234-
1. Your app should be up and running! To verify that your app
240+
7. Your app should be up and running! To verify that your app
235241
is receiving webhook data, you can tail your app's logs:
236242
237243
$ heroku config:set LOG_LEVEL=trace
238244
$ heroku logs --tail
239245
246+
8. SSL [Optional]: If you want to secure webhook payloads, go to Heroku app settings => Configure SSL => Automatic Certificate Management (ACM) which uses Let's encrypt (or upload your own). Then go to the GitHub app settings, and update the url to use https:// instead
247+
248+
9. Cron [Optional]: You can configure this app to run on a schedule using the var (CRON), you can set it in the app settings in the UI, or using `heroku config:set CRON='0 * * * *'` to run every hour for ex.
249+
240250
## Create the GitHub App
241251
242252
Every deployment will need an [App](https://developer.github.com/apps/).

docs/sample-settings/sample-deployment-settings.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1+
# This is a sample deployment settings file
2+
# See the documentation for more details on how to use this file
3+
4+
# If no file is specified, the following repositories are excluded by default
5+
# restrictedRepos: ['admin', '.github', 'safe-settings']
6+
17
restrictedRepos:
2-
# You can exclude certain repos from safe-settings processing
3-
# If no file is specified, then the following repositories - 'admin', '.github', 'safe-settings' are exempted by default
4-
exclude: ['^admin$', '^\.github$', '^safe-settings$', '.*-test']
5-
# Alternatively you can only include certain repos
6-
include: ['^test$']
8+
exclude:
9+
- admin
10+
- .github
11+
- safe-settings
12+
- admin-*
13+
include:
14+
- docs
15+
- core-*
16+
717
configvalidators:
818
- plugin: collaborators
919
error: |
1020
`Admin cannot be assigned to collaborators`
1121
script: |
1222
console.log(`baseConfig ${JSON.stringify(baseconfig)}`)
1323
return baseconfig.permission != 'admin'
24+
1425
overridevalidators:
1526
- plugin: branches
1627
error: |

handler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ const {
22
createLambdaFunction,
33
createProbot
44
} = require('@probot/adapter-aws-lambda-serverless')
5+
const { getProbotOctoKit } = require('./lib/proxyAwareProbotOctokit')
56

67
const appFn = require('./')
78

89
module.exports.webhooks = createLambdaFunction(appFn, {
9-
probot: createProbot()
10+
probot: createProbot({ overrides: { Octokit: getProbotOctoKit() } })
1011
})
1112

1213
module.exports.scheduler = function () {
13-
const probot = createProbot()
14+
const probot = createProbot({ overrides: { Octokit: getProbotOctoKit() } })
1415
const app = appFn(probot, {})
1516
return app.syncInstallation()
1617
}

0 commit comments

Comments
 (0)