Skip to content

Commit

Permalink
Merge pull request #1 from tvtphuc-axonivy/feature/MARP-756-Check-for…
Browse files Browse the repository at this point in the history
…-security.md-code-of-conduct.md-and-licence.md

Feature/marp 756 check for security.md code of conduct.md and licence.md
  • Loading branch information
tvtphuc-axonivy authored Dec 19, 2024
2 parents 3ec32a4 + c4cb0f4 commit 96c474b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 70 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/missing-file-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Missing File Check

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
dryRun:
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 to check SECURITY.md, CODE_OF_CONDUCT.md and LICENSE, example: axonivy-market'
default: 'axonivy-market'
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: 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-market' }}" >> $GITHUB_ENV
- name: Build with Maven
working-directory: ./github-repo-manager
run: |
mvn -B clean compile exec:java \
-DDRY_RUN="${{ env.dryRun }}" \
-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
66 changes: 0 additions & 66 deletions github-repo-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,70 +37,4 @@
<scope>test</scope>
</dependency>
</dependencies>

<pluginRepositories>
<pluginRepository>
<id>nexus.ivyteam.io</id>
<url>https://nexus.ivyteam.io/repository/maven/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

<profiles>
<profile>
<id>ScanIssues</id>
<build>
<plugins>
<plugin>
<groupId>ch.ivyteam.maven</groupId>
<artifactId>jira-plugin</artifactId>
<version>10.0.5</version>
<executions>
<execution>
<id>generate-release-notest</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-changelog</goal>
</goals>
<configuration>
<jiraServerId>axonivy.jira</jiraServerId>
<filterBy>project in (XIVY) AND fixVersion = ${ivy-version}</filterBy>
<asciiTemplate>$${key}</asciiTemplate>
<fileset>
<outputDirectory>${project.build.directory}/release-notes</outputDirectory>
<directory>${project.basedir}/src/main/release-notes</directory>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>generate-issue-report</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.axonivy.github.GitHubIssueScanner</mainClass>
<arguments>
<argument>${tag}</argument>
<argument>${branch}</argument>
<argument>${project.build.directory}/release-notes/release-notes.txt</argument>
<argument>${reportFile}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
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<String> WORKING_ORGANIZATIONS = List.of("axonivy");
private static final List<FileMeta> REQUIRED_FILES = List.of(LICENSE, SECURITY, CODE_OF_CONDUCT);
private static final List<FileMeta> REMOVE_FILES = List.of();

Expand All @@ -22,17 +22,23 @@ public static void main(String[] args) throws IOException {
System.out.println("running updates triggered by user "+user);
}
int status = 0;
List<String> 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<String> getWorkingOrganizations() {
String inputtedValue = System.getProperty("GITHUB.WORKING.ORGANIZATIONS");
return Arrays.asList(inputtedValue.split(","));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 96c474b

Please sign in to comment.