Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clients): add workflow to auto-close PR #3834

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
shortcuts marked this conversation as resolved.
Show resolved Hide resolved
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
1 change: 1 addition & 0 deletions templates/csharp/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/dart/do-not-edit-this-repository.yml
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: |
Copy link
Collaborator

@millotp millotp Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to check that the PR is targeting main, because it's possible to do bug fixes on older version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry I missed that

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)."
1 change: 1 addition & 0 deletions templates/go/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/java/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/kotlin/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/php/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/python/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/ruby/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/scala/do-not-edit-this-repository.yml
1 change: 1 addition & 0 deletions templates/swift/do-not-edit-this-repository.yml
Loading