Skip to content

Commit 1e306da

Browse files
authored
Merge branch 'main-enterprise' into fix/create-repos-during-fullsync
2 parents 4159742 + 2ce0136 commit 1e306da

30 files changed

+9039
-6412
lines changed

.eslintrc.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88
"standard"
99
],
1010
"parserOptions": {
11-
"ecmaVersion": 12
11+
"ecmaVersion": 13
1212
},
1313
"rules": {
1414
},
15-
"ignorePatterns": ["test/**/*.js"]
15+
"overrides": [
16+
{
17+
"files": ["test/**/*.js"],
18+
"env": {
19+
"jest": true
20+
}
21+
}
22+
]
1623
}

.github/actions/codeql-analysis/action.yml

-19
This file was deleted.

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ env:
3131
REGISTRY: ghcr.io
3232
IMAGE_NAME: ${{ github.repository }}
3333

34+
permissions:
35+
contents: write
36+
packages: write
37+
3438
jobs:
3539
build:
3640
if: ${{ github.actor != 'dependabot'}}
@@ -46,15 +50,15 @@ jobs:
4650
cache: 'npm'
4751
- run: npm install
4852
- name: Set up Docker Buildx
49-
uses: docker/setup-buildx-action@v3
53+
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
5054
- name: Log in to the Container registry
51-
uses: docker/login-action@v3
55+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
5256
with:
5357
registry: ${{ env.REGISTRY }}
5458
username: ${{ github.actor }}
5559
password: ${{ secrets.GITHUB_TOKEN }}
5660
- name: Build Docker Image Locally
57-
uses: docker/build-push-action@master
61+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
5862
with:
5963
context: .
6064
file: ./Dockerfile
@@ -73,15 +77,15 @@ jobs:
7377
- run: echo "${{ github.ref }}"
7478
- name: Tag a final release
7579
id: prerelease
76-
uses: actionsdesk/semver@0.6.0-rc.10
80+
uses: actionsdesk/semver@82aa4310e4e21c59cd0020007a4278e733e81dcb
7781
with:
7882
bump: ${{ inputs.bump }}
7983
prerelease: ${{ inputs.prerelease }}
8084
prelabel: ${{ inputs.prelabel }}
8185
commitish: ${{ github.ref }}
8286
- name: Push Docker Image
8387
if: ${{ success() }}
84-
uses: docker/build-push-action@master
88+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
8589
with:
8690
context: .
8791
file: ./Dockerfile

.github/workflows/create-release.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ env:
99
REGISTRY: ghcr.io
1010
IMAGE_NAME: ${{ github.repository }}
1111

12+
permissions:
13+
contents: write
14+
packages: write
15+
1216
jobs:
1317
build:
1418
if: ${{ github.actor != 'dependabot'}}
@@ -24,15 +28,15 @@ jobs:
2428
cache: "npm"
2529
- run: npm install
2630
- name: Set up Docker Buildx
27-
uses: docker/setup-buildx-action@v3
31+
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
2832
- name: Log in to the Container registry
29-
uses: docker/login-action@v3
33+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
3034
with:
3135
registry: ${{ env.REGISTRY }}
3236
username: ${{ github.actor }}
3337
password: ${{ secrets.GITHUB_TOKEN }}
3438
- name: Build Docker Image Locally
35-
uses: docker/build-push-action@master
39+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
3640
with:
3741
context: .
3842
file: ./Dockerfile
@@ -50,12 +54,12 @@ jobs:
5054
curl http://localhost:3000
5155
- name: Tag a final release
5256
id: finalrelease
53-
uses: actionsdesk/semver@0.6.0-rc.10
57+
uses: actionsdesk/semver@82aa4310e4e21c59cd0020007a4278e733e81dcb
5458
with:
5559
bump: final
5660
- name: Push Docker Image
5761
if: ${{ success() }}
58-
uses: docker/build-push-action@master
62+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
5963
with:
6064
context: .
6165
file: ./Dockerfile

.github/workflows/deploy-k8s.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ jobs:
2929
steps:
3030
- name: Checkout repository
3131
uses: actions/checkout@v4
32-
- uses: azure/login@v2
32+
- uses: azure/login@a65d910e8af852a8061c627c456678983e180302
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@v4
37+
- uses: azure/aks-set-context@feeca6405be94202afcb1c395616ff29b1811b9f
3838
with:
3939
resource-group: ${{env.AZURE_RESOURCE_GROUP}}
4040
cluster-name: ${{env.AZURE_AKS_CLUSTER}}
4141
id: login
4242
- run: |
4343
kubectl get deployment
4444
- name: app-env
45-
uses: azure/k8s-create-secret@v5
45+
uses: azure/k8s-create-secret@6e0ba8047235646753f2a3a3b359b4d0006ff218
4646
with:
4747
namespace: 'default'
4848
secret-type: 'generic'
4949
arguments: --from-literal=APP_ID=${{ secrets.APP_ID }} --from-literal=PRIVATE_KEY=${{ secrets.PRIVATE_KEY }} --from-literal=WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET }}
5050
secret-name: app-env
5151
- name: Set imagePullSecret
52-
uses: azure/k8s-create-secret@v5
52+
uses: azure/k8s-create-secret@6e0ba8047235646753f2a3a3b359b4d0006ff218
5353
with:
5454
namespace: ${{env.AZURE_AKS_NAMESPACE}}
5555
container-registry-url: ${{env.IMAGE_REGISTRY_URL}}

.github/workflows/node-ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Node.js CI
22
on:
33
pull_request:
44

5+
permissions:
6+
contents: read
7+
58
concurrency:
69
group: ${{ github.workflow }}-${{ github.ref }}
710
cancel-in-progress: true

.github/workflows/rc-release.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Tag a rc release
3636
if: ${{ !github.event.pull_request.head.repo.fork }}
3737
id: rcrelease
38-
uses: actionsdesk/semver@0.6.0-rc.10
38+
uses: actionsdesk/semver@82aa4310e4e21c59cd0020007a4278e733e81dcb
3939
with:
4040
prerelease: withBuildNumber
4141
prelabel: rc
@@ -60,23 +60,23 @@ jobs:
6060
- run: echo ${{ github.actor }}
6161

6262
- name: Log in to the Container registry
63-
uses: docker/login-action@v3
63+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
6464
with:
6565
registry: ${{ env.REGISTRY }}
6666
username: ${{ github.actor }}
6767
password: ${{ secrets.GITHUB_TOKEN }}
6868

6969
- name: Extract metadata
7070
id: meta
71-
uses: docker/metadata-action@v5
71+
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
7272
with:
7373
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
7474
- name: Set up QEMU
75-
uses: docker/setup-qemu-action@v3
75+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
7676
- name: Set up Docker Buildx
77-
uses: docker/setup-buildx-action@v3
77+
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
7878
- name: Build and push Docker image
79-
uses: docker/build-push-action@master
79+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
8080
with:
8181
context: .
8282
push: true

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ You can pass environment variables; the easiest way to do it is via a `.env` fil
382382
383383
## How to use
384384
385-
1. Create an `admin` repo (or an alternative of your choosing) within your organization. Remember to set `CONFIG_REPO` if you choose something other than `admin`. See [Environment variables](#environment-variables) for more details.
385+
1. Create an `admin` repo (or an alternative of your choosing) within your organization. Remember to set `ADMIN_REPO` if you choose something other than `admin`. See [Environment variables](#environment-variables) for more details.
386386
387387
2. Add the settings for the `org`, `suborgs`, and `repos`. Sample files can be found [here](docs/sample-settings).
388388

index.js

+15-22
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const env = require('./lib/env')
99

1010
let deploymentConfig
1111

12-
1312
module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) => {
14-
let appName = 'safe-settings'
1513
let appSlug = 'safe-settings'
1614
async function syncAllSettings (nop, context, repo = context.repo(), ref) {
1715
try {
@@ -101,7 +99,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
10199
const config = Object.assign({}, deploymentConfig, runtimeConfig)
102100
const renameConfig = Object.assign({}, config, rename)
103101
robot.log.debug(`config for ref ${ref} is ${JSON.stringify(config)}`)
104-
return Settings.sync(nop, context, repo, renameConfig, ref )
102+
return Settings.sync(nop, context, repo, renameConfig, ref)
105103
} catch (e) {
106104
if (nop) {
107105
let filename = env.SETTINGS_FILE_PATH
@@ -217,7 +215,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
217215
robot.log.debug(JSON.stringify(res, null))
218216
}
219217

220-
async function info() {
218+
async function info () {
221219
const github = await robot.auth()
222220
const installations = await github.paginate(
223221
github.apps.listInstallations.endpoint.merge({ per_page: 100 })
@@ -227,13 +225,11 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
227225
const installation = installations[0]
228226
const github = await robot.auth(installation.id)
229227
const app = await github.apps.getAuthenticated()
230-
appName = app.data.name
231228
appSlug = app.data.slug
232229
robot.log.debug(`Validated the app is configured properly = \n${JSON.stringify(app.data, null, 2)}`)
233230
}
234231
}
235232

236-
237233
async function syncInstallation () {
238234
robot.log.trace('Fetching installations')
239235
const github = await robot.auth()
@@ -395,8 +391,8 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
395391
})
396392

397393
robot.on('repository.renamed', async context => {
398-
if (env.BLOCK_REPO_RENAME_BY_HUMAN!== 'true') {
399-
robot.log.debug(`"env.BLOCK_REPO_RENAME_BY_HUMAN" is 'false' by default. Repo rename is not managed by Safe-settings. Continue with the default behavior.`)
394+
if (env.BLOCK_REPO_RENAME_BY_HUMAN !== 'true') {
395+
robot.log.debug('"env.BLOCK_REPO_RENAME_BY_HUMAN" is \'false\' by default. Repo rename is not managed by Safe-settings. Continue with the default behavior.')
400396
return
401397
}
402398
const { payload } = context
@@ -414,7 +410,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
414410
const newPath = `.github/repos/${payload.repository.name}.yml`
415411
robot.log.debug(oldPath)
416412
try {
417-
const repofile = await context.octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
413+
const repofile = await context.octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
418414
owner: payload.repository.owner.login,
419415
repo: env.ADMIN_REPO,
420416
path: oldPath,
@@ -439,12 +435,12 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
439435
} catch (error) {
440436
if (error.status === 404) {
441437
// if the a config file does not exist, create one from the old one
442-
const update = await context.octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', {
438+
await context.octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', {
443439
owner: payload.repository.owner.login,
444440
repo: env.ADMIN_REPO,
445441
path: newPath,
446-
name: `${payload.repository.name}.yml`,
447-
content: content,
442+
name: `${payload.repository.name}.yml`,
443+
content,
448444
message: `Repo Renamed and safe-settings renamed the file from ${payload.changes.repository.name.from} to ${payload.repository.name}`,
449445
sha: repofile.data.sha,
450446
headers: {
@@ -455,26 +451,23 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
455451
} else {
456452
robot.log.error(error)
457453
}
458-
}
459-
454+
}
460455
} catch (error) {
461456
if (error.status === 404) {
462-
//nop
463-
} else {
457+
// nop
458+
} else {
464459
robot.log.error(error)
465460
}
466-
}
467-
return
461+
}
468462
} else {
469463
robot.log.debug('Repository Edited by a Human')
470464
// Create a repository config to reset the name back to the previous name
471-
const rename = {repository: { name: payload.changes.repository.name.from, oldname: payload.repository.name}}
472-
const repo = {repo: payload.changes.repository.name.from, owner: payload.repository.owner.login}
465+
const rename = { repository: { name: payload.changes.repository.name.from, oldname: payload.repository.name } }
466+
const repo = { repo: payload.changes.repository.name.from, owner: payload.repository.owner.login }
473467
return renameSync(false, context, repo, rename)
474468
}
475469
})
476470

477-
478471
robot.on('check_suite.requested', async context => {
479472
const { payload } = context
480473
const { repository } = payload
@@ -663,7 +656,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
663656
syncInstallation()
664657
})
665658
}
666-
659+
667660
// Get info about the app
668661
info()
669662

lib/commentmessage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ module.exports = `* Run on: \` <%= new Date() %> \`
2828
<% }) %>
2929
3030
<% }) %>
31-
<% } %>`
31+
<% } %>`

0 commit comments

Comments
 (0)