Skip to content

Commit

Permalink
chore(clients): add workflow to auto-close PR
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Sep 25, 2024
1 parent da95580 commit 1faa9fd
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "../", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", "../.github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", "../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", "../.github/workflows/", "do-not-edit-this-repository.yml"));

reservedWords.removeIf(word -> word.equals("Configuration"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "../client_core/", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", "../../.github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", "../../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(
new SupportingFile("do-not-edit-this-repository.yml", "../../.github/workflows/", "do-not-edit-this-repository.yml")
);

// Search config
additionalProperties.put("isSearchClient", client.equals("search"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "../../", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", "../../.github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", "../../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(
new SupportingFile("do-not-edit-this-repository.yml", "../../.github/workflows/", "do-not-edit-this-repository.yml")
);

try {
additionalProperties.put("packageVersion", Helpers.getClientConfigField("go", "packageVersion"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", ".github/workflows/", "do-not-edit-this-repository.yml"));

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "../../LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", "../../.github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", "../../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(
new SupportingFile("do-not-edit-this-repository.yml", "../../.github/workflows/", "do-not-edit-this-repository.yml")
);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", ".github/workflows/", "do-not-edit-this-repository.yml"));

additionalProperties.put("packageVersion", Helpers.getClientConfigField("kotlin", "packageVersion"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", ".github/workflows/", "do-not-edit-this-repository.yml"));

additionalProperties.put("isSearchClient", client.equals("search"));
additionalProperties.put("configClassname", getClientName(client) + "Config");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "../", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", "../.github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", "../.github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", "../.github/workflows/", "do-not-edit-this-repository.yml"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", ".github/workflows/", "do-not-edit-this-repository.yml"));

// Remove some files we don't want to output or change their paths
supportingFiles.removeIf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", ".github/workflows/", "do-not-edit-this-repository.yml"));

additionalProperties.put("isSearchClient", client.equals("search"));
typeMapping.put("AnyType", "Any");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
supportingFiles.add(new SupportingFile("issue.yml", ".github/workflows", "issue.yml"));
supportingFiles.add(new SupportingFile("Bug_report.yml", ".github/ISSUE_TEMPLATE", "Bug_report.yml"));
supportingFiles.add(new SupportingFile("do-not-edit-this-repository.yml", ".github/workflows/", "do-not-edit-this-repository.yml"));

supportingFiles.add(new SupportingFile("Package.mustache", "Package.swift"));
supportingFiles.add(new SupportingFile("podspec.mustache", projectName + ".podspec"));
Expand Down
24 changes: 24 additions & 0 deletions templates/do-not-edit-this-repository.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Do not edit files in this repository

on:
pull_request:
types:
- opened
- synchronize
- reopen
branches:
- 'main'

jobs:
auto_close_pr:
name: Close PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Close PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
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)."

0 comments on commit 1faa9fd

Please sign in to comment.