From 2b72285592c3899a2b1cd2c21d010905f4bcfeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Mon, 16 Dec 2024 11:18:51 +0700 Subject: [PATCH 01/10] MARP-756 create github action runner to run GihubMissingFiles --- .github/workflows/check-missing-files.yml | 49 +++++++++++++++++++ .../pom_check_missing_file.xml | 40 +++++++++++++++ .../github/file/GitHubMissingFiles.java | 2 +- 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-missing-files.yml create mode 100644 github-repo-manager/pom_check_missing_file.xml diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml new file mode 100644 index 0000000..0e23ae9 --- /dev/null +++ b/.github/workflows/check-missing-files.yml @@ -0,0 +1,49 @@ +name: Checking missing files + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + inputs: + dryRun: + description: 'Whether the build should really make a change or not' + required: true + default: 'true' + push: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Setup Maven + uses: stCarolas/setup-maven@v5 + + - name: Create a file with TOKEN value + run: | + echo -n "${{ secrets.TOKEN }}" > token_file + echo "File created at: $(pwd)/token_file" + + - name: Get the file path + id: get-file-path + run: echo "::set-output name=filepath::$(pwd)/token_file" + + - name: Build with Maven + working-directory: ./github-repo-manager + run: mvn -f pom_check_missing_file.xml -B clean compile exec:java -DDRY_RUN="true" -"DGITHUB.TOKEN.FILE"="${{ steps.get-file-path.outputs.filepath }}" -"Dexec.mainClass"="com.axonivy.github.file.GitHubMissingFiles" -"Dexec.args"="${{ github.actor }}" + + - name: Delete TOKEN file + run: | + rm token_file + echo "Token file deleted." diff --git a/github-repo-manager/pom_check_missing_file.xml b/github-repo-manager/pom_check_missing_file.xml new file mode 100644 index 0000000..0999223 --- /dev/null +++ b/github-repo-manager/pom_check_missing_file.xml @@ -0,0 +1,40 @@ + + 4.0.0 + com.axonivy.github + github-repo-manager + 0.0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 17 + + + + + + + + org.kohsuke + github-api + 1.326 + + + + org.junit.jupiter + junit-jupiter-engine + 5.11.3 + test + + + org.assertj + assertj-core + 3.26.3 + test + + + diff --git a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java index e183409..1314ece 100644 --- a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java +++ b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java @@ -11,7 +11,7 @@ public class GitHubMissingFiles { - private static final List WORKING_ORGANIZATIONS = List.of("axonivy"); + private static final List WORKING_ORGANIZATIONS = List.of("axonivy-market"); private static final List REQUIRED_FILES = List.of(LICENSE, SECURITY, CODE_OF_CONDUCT); private static final List REMOVE_FILES = List.of(); From 4c27f88aa2d0cf954045dc2f88fe1ec07a35adb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 17 Dec 2024 14:10:54 +0700 Subject: [PATCH 02/10] MARP-756 Handle Feedbacks --- .github/workflows/check-missing-files.yml | 21 ++++++++++++++++--- .../github/file/GitHubMissingFiles.java | 13 +++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml index 0e23ae9..52ecc34 100644 --- a/.github/workflows/check-missing-files.yml +++ b/.github/workflows/check-missing-files.yml @@ -7,8 +7,10 @@ on: inputs: dryRun: description: 'Whether the build should really make a change or not' - required: true default: 'true' + workingOrgs: + description: 'Working Organizations to Scan' + default: 'axonivy,axonivy-market' push: branches: [ "master" ] @@ -39,10 +41,23 @@ jobs: id: get-file-path run: echo "::set-output name=filepath::$(pwd)/token_file" + - name: Set default values for dryRun and workingOrgs + id: set-defaults + run: | + echo "dryRun=${{ github.event.inputs.dryRun || 'true' }}" >> $GITHUB_ENV + echo "workingOrgs=${{ github.event.inputs.workingOrgs || 'axonivy,axonivy-market' }}" >> $GITHUB_ENV + - name: Build with Maven working-directory: ./github-repo-manager - run: mvn -f pom_check_missing_file.xml -B clean compile exec:java -DDRY_RUN="true" -"DGITHUB.TOKEN.FILE"="${{ steps.get-file-path.outputs.filepath }}" -"Dexec.mainClass"="com.axonivy.github.file.GitHubMissingFiles" -"Dexec.args"="${{ github.actor }}" - + run: | + mvn -f pom_check_missing_file.xml -B clean compile exec:java \ + -DDRY_RUN="${{ env.dryRun }}" \ + -DGITHUB.TOKEN.FILE="${{ steps.get-file-path.outputs.filepath }}" \ + -Dexec.mainClass="com.axonivy.github.file.GitHubMissingFiles" \ + -Dexec.args="${{ github.actor }}" \ + -DGITHUB.WORKING.ORGANIZATIONS="${{ env.workingOrgs }}" + continue-on-error: true + - name: Delete TOKEN file run: | rm token_file diff --git a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java index 1314ece..d44c070 100644 --- a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java +++ b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java @@ -5,13 +5,14 @@ import static com.axonivy.github.file.GitHubFiles.SECURITY; import java.io.IOException; +import java.util.Arrays; import java.util.List; import com.axonivy.github.file.GitHubFiles.FileMeta; public class GitHubMissingFiles { - private static final List WORKING_ORGANIZATIONS = List.of("axonivy-market"); + private static final List WORKING_ORGANIZATIONS = List.of("axonivy"); private static final List REQUIRED_FILES = List.of(LICENSE, SECURITY, CODE_OF_CONDUCT); private static final List REMOVE_FILES = List.of(); @@ -22,17 +23,23 @@ public static void main(String[] args) throws IOException { System.out.println("running updates triggered by user "+user); } int status = 0; + List workingOrganizations = getWorkingOrganizations(); for (var fileMeta : REQUIRED_FILES) { var detector = new GitHubMissingFilesDetector(fileMeta, user); - var returnedStatus = detector.requireFile(WORKING_ORGANIZATIONS); + var returnedStatus = detector.requireFile(workingOrganizations); status = returnedStatus != 0 ? returnedStatus : status; } for (var fileMeta : REMOVE_FILES) { var detector = new GitHubFilesRemover(fileMeta, user); - var returnedStatus = detector.removeFile(WORKING_ORGANIZATIONS); + var returnedStatus = detector.removeFile(workingOrganizations); status = returnedStatus != 0 ? returnedStatus : status; } System.exit(status); } + private static List getWorkingOrganizations() { + String inputtedValue = System.getProperty("GITHUB.WORKING.ORGANIZATIONS", String.join(",", WORKING_ORGANIZATIONS)); + return Arrays.asList(inputtedValue.split(",")); + } + } From 9d9e462baeaecc87e9db6a7dc335ca17ed517d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 17 Dec 2024 17:11:59 +0700 Subject: [PATCH 03/10] MARP-756 Handle Feedbacks --- .github/workflows/check-missing-files.yml | 6 +++--- .../java/com/axonivy/github/file/GitHubMissingFiles.java | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml index 52ecc34..45a9789 100644 --- a/.github/workflows/check-missing-files.yml +++ b/.github/workflows/check-missing-files.yml @@ -6,10 +6,10 @@ on: workflow_dispatch: inputs: dryRun: - description: 'Whether the build should really make a change or not' + description: 'Indicates whether to trigger changes to a product. By default, `dryRun` is set to `true`, meaning the action will perform a check without applying changes. When set to `false`, the action will both check for and add any missing files to the products.' default: 'true' workingOrgs: - description: 'Working Organizations to Scan' + description: 'Define organizations must be checked ex: axonivy,axonivy-market' default: 'axonivy,axonivy-market' push: branches: [ "master" ] @@ -61,4 +61,4 @@ jobs: - name: Delete TOKEN file run: | rm token_file - echo "Token file deleted." + echo "Token file removed successfully." diff --git a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java index d44c070..ef9712c 100644 --- a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java +++ b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFiles.java @@ -12,7 +12,6 @@ public class GitHubMissingFiles { - private static final List WORKING_ORGANIZATIONS = List.of("axonivy"); private static final List REQUIRED_FILES = List.of(LICENSE, SECURITY, CODE_OF_CONDUCT); private static final List REMOVE_FILES = List.of(); @@ -38,7 +37,7 @@ public static void main(String[] args) throws IOException { } private static List getWorkingOrganizations() { - String inputtedValue = System.getProperty("GITHUB.WORKING.ORGANIZATIONS", String.join(",", WORKING_ORGANIZATIONS)); + String inputtedValue = System.getProperty("GITHUB.WORKING.ORGANIZATIONS"); return Arrays.asList(inputtedValue.split(",")); } From 2cbd968ea27b28ae822d6905112d57514aad0912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 17 Dec 2024 17:32:49 +0700 Subject: [PATCH 04/10] MARP-756 Handle Feedbacks --- .github/workflows/check-missing-files.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml index 45a9789..6d96aef 100644 --- a/.github/workflows/check-missing-files.yml +++ b/.github/workflows/check-missing-files.yml @@ -9,7 +9,7 @@ on: description: 'Indicates whether to trigger changes to a product. By default, `dryRun` is set to `true`, meaning the action will perform a check without applying changes. When set to `false`, the action will both check for and add any missing files to the products.' default: 'true' workingOrgs: - description: 'Define organizations must be checked ex: axonivy,axonivy-market' + description: 'Define organizations must be checked, example: axonivy,axonivy-market' default: 'axonivy,axonivy-market' push: branches: [ "master" ] From 0476fa8488cc5427173c55ae0c29871bc6d1c960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Thu, 19 Dec 2024 09:01:09 +0700 Subject: [PATCH 05/10] MARP-756 Handle Feedbacks --- .github/workflows/check-missing-files.yml | 22 ++++--------------- .../com/axonivy/github/GitHubProvider.java | 9 ++++++++ .../file/GitHubMissingFilesDetector.java | 2 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml index 6d96aef..9930ccf 100644 --- a/.github/workflows/check-missing-files.yml +++ b/.github/workflows/check-missing-files.yml @@ -9,8 +9,8 @@ on: description: 'Indicates whether to trigger changes to a product. By default, `dryRun` is set to `true`, meaning the action will perform a check without applying changes. When set to `false`, the action will both check for and add any missing files to the products.' default: 'true' workingOrgs: - description: 'Define organizations must be checked, example: axonivy,axonivy-market' - default: 'axonivy,axonivy-market' + description: 'Define organizations must be checked, example: axonivy-market' + default: 'axonivy-market' push: branches: [ "master" ] @@ -32,33 +32,19 @@ jobs: - name: Setup Maven uses: stCarolas/setup-maven@v5 - - name: Create a file with TOKEN value - run: | - echo -n "${{ secrets.TOKEN }}" > token_file - echo "File created at: $(pwd)/token_file" - - - name: Get the file path - id: get-file-path - run: echo "::set-output name=filepath::$(pwd)/token_file" - - name: Set default values for dryRun and workingOrgs id: set-defaults run: | echo "dryRun=${{ github.event.inputs.dryRun || 'true' }}" >> $GITHUB_ENV - echo "workingOrgs=${{ github.event.inputs.workingOrgs || 'axonivy,axonivy-market' }}" >> $GITHUB_ENV + echo "workingOrgs=${{ github.event.inputs.workingOrgs || 'axonivy-market' }}" >> $GITHUB_ENV - name: Build with Maven working-directory: ./github-repo-manager run: | mvn -f pom_check_missing_file.xml -B clean compile exec:java \ -DDRY_RUN="${{ env.dryRun }}" \ - -DGITHUB.TOKEN.FILE="${{ steps.get-file-path.outputs.filepath }}" \ + -DGITHUB.TOKEN.FILE="${{ secrets.TOKEN }}" \ -Dexec.mainClass="com.axonivy.github.file.GitHubMissingFiles" \ -Dexec.args="${{ github.actor }}" \ -DGITHUB.WORKING.ORGANIZATIONS="${{ env.workingOrgs }}" continue-on-error: true - - - name: Delete TOKEN file - run: | - rm token_file - echo "Token file removed successfully." diff --git a/github-repo-manager/src/main/java/com/axonivy/github/GitHubProvider.java b/github-repo-manager/src/main/java/com/axonivy/github/GitHubProvider.java index e5ff31a..d213812 100644 --- a/github-repo-manager/src/main/java/com/axonivy/github/GitHubProvider.java +++ b/github-repo-manager/src/main/java/com/axonivy/github/GitHubProvider.java @@ -21,4 +21,13 @@ public static GitHub get() { throw new RuntimeException(ex); } } + + public static GitHub getGithubToken() { + String token = System.getProperty("GITHUB.TOKEN.FILE"); + try { + return new GitHubBuilder().withOAuthToken(token).build(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } } diff --git a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFilesDetector.java b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFilesDetector.java index 011d2e4..e90ee53 100644 --- a/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFilesDetector.java +++ b/github-repo-manager/src/main/java/com/axonivy/github/file/GitHubMissingFilesDetector.java @@ -28,7 +28,7 @@ public class GitHubMissingFilesDetector { public GitHubMissingFilesDetector(FileMeta fileMeta, String user) throws IOException { Objects.requireNonNull(fileMeta); this.reference = new FileReference(fileMeta); - this.github = GitHubProvider.get(); + this.github = GitHubProvider.getGithubToken(); this.ghActor = github.getUser(user); } From f8ab1b92a6c9a3112bf7d222542ca5feae7836e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Thu, 19 Dec 2024 10:03:59 +0700 Subject: [PATCH 06/10] MARP-756 Handle Feedbacks --- .github/workflows/check-missing-files.yml | 2 +- github-repo-manager/pom.xml | 66 ------------------- .../pom_check_missing_file.xml | 40 ----------- 3 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 github-repo-manager/pom_check_missing_file.xml diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml index 9930ccf..9c47249 100644 --- a/.github/workflows/check-missing-files.yml +++ b/.github/workflows/check-missing-files.yml @@ -41,7 +41,7 @@ jobs: - name: Build with Maven working-directory: ./github-repo-manager run: | - mvn -f pom_check_missing_file.xml -B clean compile exec:java \ + mvn -B clean compile exec:java \ -DDRY_RUN="${{ env.dryRun }}" \ -DGITHUB.TOKEN.FILE="${{ secrets.TOKEN }}" \ -Dexec.mainClass="com.axonivy.github.file.GitHubMissingFiles" \ diff --git a/github-repo-manager/pom.xml b/github-repo-manager/pom.xml index 0bea59a..0999223 100644 --- a/github-repo-manager/pom.xml +++ b/github-repo-manager/pom.xml @@ -37,70 +37,4 @@ test - - - - nexus.ivyteam.io - https://nexus.ivyteam.io/repository/maven/ - - always - - - - - - - ScanIssues - - - - ch.ivyteam.maven - jira-plugin - 10.0.5 - - - generate-release-notest - generate-resources - - generate-changelog - - - axonivy.jira - project in (XIVY) AND fixVersion = ${ivy-version} - $${key} - - ${project.build.directory}/release-notes - ${project.basedir}/src/main/release-notes - - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.5.0 - - - generate-issue-report - process-classes - - java - - - - - com.axonivy.github.GitHubIssueScanner - - ${tag} - ${branch} - ${project.build.directory}/release-notes/release-notes.txt - ${reportFile} - - - - - - - diff --git a/github-repo-manager/pom_check_missing_file.xml b/github-repo-manager/pom_check_missing_file.xml deleted file mode 100644 index 0999223..0000000 --- a/github-repo-manager/pom_check_missing_file.xml +++ /dev/null @@ -1,40 +0,0 @@ - - 4.0.0 - com.axonivy.github - github-repo-manager - 0.0.1-SNAPSHOT - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 17 - - - - - - - - org.kohsuke - github-api - 1.326 - - - - org.junit.jupiter - junit-jupiter-engine - 5.11.3 - test - - - org.assertj - assertj-core - 3.26.3 - test - - - From b3a29b89bef9c20392eaa7090bbab18f7f140367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Thu, 19 Dec 2024 11:08:23 +0700 Subject: [PATCH 07/10] MARP-756 Handle Feedbacks --- .github/workflows/check-missing-files.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/check-missing-files.yml index 9c47249..29c8a9c 100644 --- a/.github/workflows/check-missing-files.yml +++ b/.github/workflows/check-missing-files.yml @@ -1,4 +1,4 @@ -name: Checking missing files +name: Missing File Check on: schedule: @@ -9,7 +9,7 @@ on: description: 'Indicates whether to trigger changes to a product. By default, `dryRun` is set to `true`, meaning the action will perform a check without applying changes. When set to `false`, the action will both check for and add any missing files to the products.' default: 'true' workingOrgs: - description: 'Define organizations must be checked, example: axonivy-market' + description: 'Define organizations to check SECURITY.md, CODE_OF_CONDUCT.md and LICENSE, example: axonivy-market' default: 'axonivy-market' push: branches: [ "master" ] From 207e345be345de4076afbabc10a6bcee341eb5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Thu, 19 Dec 2024 11:20:44 +0700 Subject: [PATCH 08/10] MARP-756 Handle Feedbacks --- .../workflows/{check-missing-files.yml => Missing-File-Check.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{check-missing-files.yml => Missing-File-Check.yml} (100%) diff --git a/.github/workflows/check-missing-files.yml b/.github/workflows/Missing-File-Check.yml similarity index 100% rename from .github/workflows/check-missing-files.yml rename to .github/workflows/Missing-File-Check.yml From 32bb07cd9f038d5ff7c81462490c2a2bfa5a012e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Thu, 19 Dec 2024 11:25:46 +0700 Subject: [PATCH 09/10] MARP-756 Handle Feedbacks --- .../{Missing-File-Check.yml => missing-file-check_temp.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{Missing-File-Check.yml => missing-file-check_temp.yml} (100%) diff --git a/.github/workflows/Missing-File-Check.yml b/.github/workflows/missing-file-check_temp.yml similarity index 100% rename from .github/workflows/Missing-File-Check.yml rename to .github/workflows/missing-file-check_temp.yml From c4cb0f411078181a96c47719302c4253648df2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Thu, 19 Dec 2024 11:26:03 +0700 Subject: [PATCH 10/10] MARP-756 Handle Feedbacks --- .../{missing-file-check_temp.yml => missing-file-check.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{missing-file-check_temp.yml => missing-file-check.yml} (100%) diff --git a/.github/workflows/missing-file-check_temp.yml b/.github/workflows/missing-file-check.yml similarity index 100% rename from .github/workflows/missing-file-check_temp.yml rename to .github/workflows/missing-file-check.yml