@sapphire-sh/utils 3.6.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,6 +20,7 @@ const workflowsDir = join('.github', 'workflows');
|
|
|
20
20
|
const workflowValuesPath = join('.github', 'sapphire-workflows.json');
|
|
21
21
|
const withLinePattern = /^\s*with:\s*$/m;
|
|
22
22
|
const pathsIgnoreLinePattern = /^\s*paths-ignore:\s*$/m;
|
|
23
|
+
const reviewersOnlyBlockPattern = /^\n {6}reviewers: .*\n$/;
|
|
23
24
|
const pushBlockPattern = /^on:\n(?:[ \t].*\n|\n)*? {2}push:\n((?: {4}.*\n|\n)*)/m;
|
|
24
25
|
const branchesListPattern = /^ {2}push:\n {4}branches:\n(?: {6}- .*\n)*/m;
|
|
25
26
|
const entryKeys = new Set(['push', 'with']);
|
|
@@ -64,7 +65,7 @@ const readWorkflowValues = () => {
|
|
|
64
65
|
|
|
65
66
|
const codeOwnersPath = join('.github', 'CODEOWNERS');
|
|
66
67
|
|
|
67
|
-
const
|
|
68
|
+
const readCodeOwnerUsers = () => {
|
|
68
69
|
const filepath = join(cwd, codeOwnersPath);
|
|
69
70
|
|
|
70
71
|
if (existsSync(filepath) === false) {
|
|
@@ -125,8 +126,17 @@ const writeWorkflow = (outputName, template) => {
|
|
|
125
126
|
let content = template;
|
|
126
127
|
|
|
127
128
|
if (values === undefined) {
|
|
128
|
-
if (existsSync(filepath)
|
|
129
|
-
|
|
129
|
+
if (existsSync(filepath)) {
|
|
130
|
+
const existing = readFileSync(filepath, 'utf-8');
|
|
131
|
+
const withLine = withLinePattern.exec(existing);
|
|
132
|
+
|
|
133
|
+
if (
|
|
134
|
+
withLine !== null &&
|
|
135
|
+
(basename(outputName, '.yml') !== 'dependabot-review-request' ||
|
|
136
|
+
reviewersOnlyBlockPattern.test(existing.slice(withLine.index + withLine[0].length)) === false)
|
|
137
|
+
) {
|
|
138
|
+
console.log(`warning: ${outputName} had with: values that are not in ${workflowValuesPath}`);
|
|
139
|
+
}
|
|
130
140
|
}
|
|
131
141
|
} else {
|
|
132
142
|
const { push = {}, with: withValues } = values;
|
|
@@ -147,6 +157,18 @@ const writeWorkflow = (outputName, template) => {
|
|
|
147
157
|
}
|
|
148
158
|
}
|
|
149
159
|
|
|
160
|
+
if (basename(outputName, '.yml') === 'dependabot-review-request') {
|
|
161
|
+
const reviewers = readCodeOwnerUsers();
|
|
162
|
+
|
|
163
|
+
if (reviewers.length > 0) {
|
|
164
|
+
if (withLinePattern.test(content) === false) {
|
|
165
|
+
content += ' with:\n';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
content += ` reviewers: ${formatYamlValue(reviewers.join(' '))}\n`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
150
172
|
if (
|
|
151
173
|
(values?.push === undefined || Object.hasOwn(values.push, 'paths-ignore') === false) &&
|
|
152
174
|
existsSync(filepath) &&
|
|
@@ -200,7 +222,7 @@ const writeDependabotConfig = (outputName, template) => {
|
|
|
200
222
|
);
|
|
201
223
|
}
|
|
202
224
|
|
|
203
|
-
const assignees =
|
|
225
|
+
const assignees = readCodeOwnerUsers();
|
|
204
226
|
|
|
205
227
|
if (assignees.length > 0) {
|
|
206
228
|
const assigneeLines = assignees.map((assignee) => ` - ${formatYamlValue(assignee)}\n`).join('');
|
package/package.json
CHANGED
|
@@ -13,6 +13,9 @@ concurrency:
|
|
|
13
13
|
jobs:
|
|
14
14
|
call-shared-ci:
|
|
15
15
|
uses: sapphire-sh/github-actions/.github/workflows/docker-publish-template.yml@main
|
|
16
|
+
permissions:
|
|
17
|
+
actions: read
|
|
18
|
+
contents: read
|
|
16
19
|
secrets: inherit
|
|
17
20
|
with:
|
|
18
21
|
image_name: ${{ github.event.repository.name }}
|