Skip to content

Commit 7884835

Browse files
authoredSep 26, 2024··
chore(clients): add workflow to auto-close PR (#3834)
1 parent 4c7e4a5 commit 7884835

24 files changed

+58
-34
lines changed
 

‎generators/src/main/java/com/algolia/codegen/AlgoliaCSharpGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ public void processOpts() {
121121
supportingFiles.add(new SupportingFile("netcore_project.mustache", "Algolia.Search.csproj"));
122122
supportingFiles.add(new SupportingFile("Configuration.mustache", "Clients", packageName + "Configuration.cs"));
123123

124-
supportingFiles.add(new SupportingFile("LICENSE", "../", "LICENSE"));
125-
supportingFiles.add(new SupportingFile("issue.yml", "../.github/workflows", "issue.yml"));
126-
supportingFiles.add(new SupportingFile("Bug_report.yml", "../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
124+
Helpers.addCommonSupportingFiles(supportingFiles, "../");
127125

128126
reservedWords.removeIf(word -> word.equals("Configuration"));
129127
}

‎generators/src/main/java/com/algolia/codegen/AlgoliaDartGenerator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ public void processOpts() {
100100

101101
supportingFiles.add(new SupportingFile("version.mustache", srcFolder, "version.dart"));
102102
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
103-
104103
supportingFiles.add(new SupportingFile("LICENSE", "../client_core/", "LICENSE"));
105-
supportingFiles.add(new SupportingFile("issue.yml", "../../.github/workflows", "issue.yml"));
106-
supportingFiles.add(new SupportingFile("Bug_report.yml", "../../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
104+
105+
Helpers.addCommonSupportingFiles(supportingFiles, "../../");
107106

108107
// Search config
109108
additionalProperties.put("isSearchClient", client.equals("search"));

‎generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public void processOpts() {
5454
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go"));
5555
supportingFiles.add(new SupportingFile("client.mustache", "", "client.go"));
5656

57-
supportingFiles.add(new SupportingFile("LICENSE", "../../", "LICENSE"));
58-
supportingFiles.add(new SupportingFile("issue.yml", "../../.github/workflows", "issue.yml"));
59-
supportingFiles.add(new SupportingFile("Bug_report.yml", "../../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
57+
Helpers.addCommonSupportingFiles(supportingFiles, "../../");
6058

6159
try {
6260
additionalProperties.put("packageVersion", Helpers.getClientConfigField("go", "packageVersion"));

‎generators/src/main/java/com/algolia/codegen/AlgoliaJavaGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public void processOpts() {
5555
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
5656
additionalProperties.put("isSearchClient", client.equals("search"));
5757

58-
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
59-
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
60-
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
58+
Helpers.addCommonSupportingFiles(supportingFiles, "");
6159

6260
reservedWords.removeIf(word -> word.equals("configuration"));
6361

‎generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ public void processOpts() {
5959
// root export files
6060
supportingFiles.add(new SupportingFile("index.mustache", "", "index.js"));
6161
supportingFiles.add(new SupportingFile("index.d.mustache", "", "index.d.ts"));
62-
6362
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
64-
supportingFiles.add(new SupportingFile("LICENSE", "", "../../LICENSE"));
65-
supportingFiles.add(new SupportingFile("issue.yml", "../../.github/workflows", "issue.yml"));
66-
supportingFiles.add(new SupportingFile("Bug_report.yml", "../../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
63+
64+
Helpers.addCommonSupportingFiles(supportingFiles, "../../");
6765

6866
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
6967

‎generators/src/main/java/com/algolia/codegen/AlgoliaKotlinGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ public void processOpts() {
112112
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
113113
supportingFiles.add(new SupportingFile("README_BOM.mustache", "client-bom", "README.md"));
114114

115-
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
116-
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
117-
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
115+
Helpers.addCommonSupportingFiles(supportingFiles, "");
118116

119117
additionalProperties.put("packageVersion", Helpers.getClientConfigField("kotlin", "packageVersion"));
120118
}

‎generators/src/main/java/com/algolia/codegen/AlgoliaPhpGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ public void processOpts() {
5151
supportingFiles.add(new SupportingFile("client_config.mustache", "lib/Configuration", getClientName(client) + "Config.php"));
5252
supportingFiles.add(new SupportingFile("Algolia.mustache", "lib", "Algolia.php"));
5353

54-
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
55-
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
56-
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
54+
Helpers.addCommonSupportingFiles(supportingFiles, "");
5755

5856
additionalProperties.put("isSearchClient", client.equals("search"));
5957
additionalProperties.put("configClassname", getClientName(client) + "Config");

‎generators/src/main/java/com/algolia/codegen/AlgoliaPythonGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ public void processOpts() {
8787
supportingFiles.add(new SupportingFile("__init__.mustache", "http", "__init__.py"));
8888
supportingFiles.add(new SupportingFile("config.mustache", packageName, "config.py"));
8989

90-
supportingFiles.add(new SupportingFile("LICENSE", "../", "LICENSE"));
91-
supportingFiles.add(new SupportingFile("issue.yml", "../.github/workflows", "issue.yml"));
92-
supportingFiles.add(new SupportingFile("Bug_report.yml", "../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
90+
Helpers.addCommonSupportingFiles(supportingFiles, "../");
9391
}
9492

9593
@Override

‎generators/src/main/java/com/algolia/codegen/AlgoliaRubyGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ public void processOpts() {
4242
apiTestTemplateFiles.clear();
4343
modelTestTemplateFiles.clear();
4444

45-
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
46-
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
47-
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
45+
Helpers.addCommonSupportingFiles(supportingFiles, "");
4846

4947
// Remove some files we don't want to output or change their paths
5048
supportingFiles.removeIf(

‎generators/src/main/java/com/algolia/codegen/AlgoliaScalaGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public void processOpts() {
7575
supportingFiles.add(new SupportingFile("version.mustache", "", "version.sbt"));
7676
supportingFiles.add(new SupportingFile("jsonSupport.mustache", modelFolder, "JsonSupport.scala"));
7777

78-
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
79-
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
80-
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
78+
Helpers.addCommonSupportingFiles(supportingFiles, "");
8179

8280
additionalProperties.put("isSearchClient", client.equals("search"));
8381
typeMapping.put("AnyType", "Any");

‎generators/src/main/java/com/algolia/codegen/AlgoliaSwiftGenerator.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ public void processOpts() {
197197
supportingFiles.add(
198198
new SupportingFile("client_configuration.mustache", sourceFolder, getClientName(CLIENT) + "ClientConfiguration.swift")
199199
);
200-
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
201-
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
202-
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
200+
Helpers.addCommonSupportingFiles(supportingFiles, "");
203201

204202
supportingFiles.add(new SupportingFile("Package.mustache", "Package.swift"));
205203
supportingFiles.add(new SupportingFile("podspec.mustache", projectName + ".podspec"));

‎generators/src/main/java/com/algolia/codegen/utils/Helpers.java

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.openapitools.codegen.CodegenOperation;
1515
import org.openapitools.codegen.CodegenServer;
1616
import org.openapitools.codegen.CodegenServerVariable;
17+
import org.openapitools.codegen.SupportingFile;
1718
import org.openapitools.codegen.model.OperationsMap;
1819

1920
public class Helpers {
@@ -258,6 +259,15 @@ public static void prettyPrint(Object o) {
258259
Json.prettyPrint(o);
259260
}
260261

262+
public static void addCommonSupportingFiles(List<SupportingFile> supportingFiles, String root) {
263+
supportingFiles.add(new SupportingFile("LICENSE", "", root + "LICENSE"));
264+
supportingFiles.add(new SupportingFile("issue.yml", root + ".github/workflows", "issue.yml"));
265+
supportingFiles.add(new SupportingFile("Bug_report.yml", root + ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
266+
supportingFiles.add(
267+
new SupportingFile("do-not-edit-this-repository.yml", root + ".github/workflows", "do-not-edit-this-repository.yml")
268+
);
269+
}
270+
261271
public static String getLanguageVersion(String language) throws IOException {
262272
String versionFile = language.equals("javascript")
263273
? ".nvmrc"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Do not edit files in this repository
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopen
9+
branches:
10+
- 'main'
11+
12+
jobs:
13+
auto_close_pr:
14+
name: Close PR
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Close PR
20+
env:
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
PR_NUMBER: ${{ github.event.pull_request.number }}
23+
run: |
24+
gh pr close "${PR_NUMBER}" -d -c "Thanks for contributing to our API clients! Sorry to close your PR, but this repository is fully generated, you can port your changes to [the API Clients Automation repository](https://github.com/algolia/api-clients-automation). If you need some guidance, feel free to [open an issue](https://github.com/algolia/api-clients-automation/issues) or [read our contribution guide](https://api-clients-automation.netlify.app/docs/introduction)."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../do-not-edit-this-repository.yml

0 commit comments

Comments
 (0)
Please sign in to comment.